Need help with an installer script

I'm a big fan of LibreELEC, a fork of OpenELEC both of which are intended to be Just Enough OS (JEOS) for Kodi, the media center formerly known as XBMC. I'm also a fan of games, retro emulated and new and current ones from Steam. I've been trying to find the magic bullet that will bring those three things together into one interface, as much as possible.

To that end I've messed about with GamerOS (but there is no automounting so no network drives are seen and no USB drives can be mounted) and its version of Kodi is launchable within Steam but it doesn't meet my needs since everything I wish to watch is stored on an external drive. Also the operating system does not play well with anything else. I've also looked into extending LibreELEC to see if I can get games from within their JEOS Kodi. Also not something that seems to be exactly what I need due to the lack of a good way of getting Steam to install.

I was on the LibreELEC forums when one of the users posted an installer script that they said would use a base install from the mini.iso to add RetroPie for emulation, install Kodi for media, add Steam, and use Pegasus-Frontend to manage everything in one interface. What I saw looked good to me so I hunted down the mini.iso for 20.04 LTS and saved the script. I installed the mini.iso base command line system without issue.

I chmod +x the script and ran it. It seemed to be working, a lost of stuff installed and I spent a long while as it downloaded and compiled RetroPie and installed it. Then an error hit. I tried again because the error at first appeared to be a network issue and it died at the same place again.

I asked in the unofficial Discord and got some tips and fixed the first thing only to have it hit a second thing. At this point I'd really like to make this work but I think it's above my knowledge level and I need someone to take a look at the script and see what can be fixed, because I am not a programmer and I literally don't know what is wrong.

#! /bin/bash

#this setup script is brought to you by Northbane (c) 2020
#it is known to be very crude and simple 
#IMPORTANT: only run it once! or it will most likely fubar your os

#need to install deps for RetroPie and PegasusFE
sudo apt install menu python-xdg at-spi2-core pulseaudio alsa-utils libglib2.0-bin dbus-x11 triggerhappy git dialog unzip xmlstarlet x11-xserver-utils gstreamer1.0-alsa gstreamer1.0-libav gstreamer1.0-plugins-good jq policykit-1 curl xdg-utils -y

#manually install basic package in RetroPie or it wont work
cd ~
git clone --depth=1 https://github.com/RetroPie/RetroPie-Setup.git
cd RetroPie-Setup 
sudo ./retropie_setup.sh

#installing drivers if needed + openbox & lightdm
sudo apt install ubuntu-drivers-common software-properties-common curl lightdm openbox 
sudo ubuntu-drivers autoinstall

#disabling power saving mode
#echo "#turn off screen saver and power saving" >> ~/.profile
#echo "xset s off && xset -dpms" >> ~/.profile
sed -i '1 i\xset s off && xset -dpms' ~/.xsession


#add USB automount
#git clone https://github.com/rbrito/usbmount
#sudo apt install debhelper build-essential lockfile-progs
#cd usbmount
#dpkg-buildpackage -us -uc -b
#cd ~ && sudo dpkg -i usbmount*.deb

#create autologin for current user / deprecated?
#if [ ! -e "/etc/lightdm/lightdm.conf" ]; then
#echo "[SeatDefaults]" >> ~/lightdm.conf
#echo "autologin-user=$USER" >> ~/lightdm.conf
#echo "autologin-user-timeout=0" >> ~/lightdm.conf
#echo "user-session=openbox" >> ~/lightdm.conf
#sudo mv ~/lightdm.conf /etc/lightdm/
#fi

#install pegasus fe / do this again from within retropie setup / experimental packages if scraped videos aren't working
curl https://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
sudo add-apt-repository 'deb https://dl.bintray.com/mmatyas/deb testing main'
sudo apt update
sudo apt install pegasus-frontend

# Start X as soon as autologin is complete
function enable_autostart_xwindows() {
    echo "--------------------------------------------------------------------------------"
    echo "| Enabling autostart of X Windows"
    echo "--------------------------------------------------------------------------------"
    # Create a .xsession file to launch OpenBox when startx is called
    echo 'exec openbox-session' >> ~/.xsession
    chown $USER:$USER ~/.xsession

    # Add startx to .bash_profile
    cat << EOF >> ~/.bash_profile
if [[ -z \$DISPLAY ]] && [[ \$(tty) = /dev/tty1 ]]; then
    exec startx -- >/dev/null 2>&1
fi
EOF
    chown $USER:$USER ~/.bash_profile
    echo -e "FINISHED enable_autostart_xwindows \n\n"
    sleep 2
}


#remove password from user sudoers. 
#if grep -q "$USER ALL=(ALL) NOPASSWD:ALL" "/etc/sudoers"; then
sudo sed -i -e '$a\$USER ALL=(ALL) NOPASSWD:ALL' /etc/sudoers
#remove user from sudo
sudo gpasswd -d $USER sudo

#set up custom plymouth:
cd ~
sudo apt-get install plymouth plymouth-themes plymouth-x11 -y
git clone --depth=1 https://github.com/HerbFargus/plymouth-themes.git tempthemes
sudo cp -r ~/tempthemes/. /usr/share/plymouth/themes/
rm -r -f tempthemes
sudo update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/retropie-pacman/retropie-pacman.plymouth 10
sudo update-alternatives --set default.plymouth /usr/share/plymouth/themes/retropie-pacman/retropie-pacman.plymouth
sudo update-initramfs -u
sudo cp /etc/default/grub /etc/default/grub.backup
sudo sed -i -e 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=2/g' /etc/default/grub
sudo sed -i -e 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="quiet splash"/g' /etc/default/grub
sudo update-grub

# Hide Openbox Windows and reduce visibility of terminal
function hide_openbox_windows() {
    echo "--------------------------------------------------------------------------------"
    echo "| Hiding window decorations in OpenBox"
    echo "--------------------------------------------------------------------------------"
    # Reduce the visibility of the gnome terminal by prepending these settings in the bash profile
    GNOME_TERMINAL_SETTINGS='dbus-launch gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/'

    cat << EOF >> ~/.bash_profile
$GNOME_TERMINAL_SETTINGS use-theme-colors false
$GNOME_TERMINAL_SETTINGS use-theme-transparency false
$GNOME_TERMINAL_SETTINGS foreground-color '#FFFFFF'
$GNOME_TERMINAL_SETTINGS background-color '#000000'
$GNOME_TERMINAL_SETTINGS cursor-blink-mode 'off'
$GNOME_TERMINAL_SETTINGS scrollbar-policy 'never'
$GNOME_TERMINAL_SETTINGS audible-bell 'false'
gsettings set org.gnome.Terminal.Legacy.Settings default-show-menubar false
EOF
    chown $USER:$USER ~/.bash_profile

    # Further reduce the visibility of windows (terminal) by modifying the OpenBox config
    mkdir -p ~/.config/openbox
    cp /etc/xdg/openbox/rc.xml ~/.config/openbox/rc.xml
    cat << EOF > /tmp/rc.xml.applications
        <application class="*">
            <fullscreen>yes</fullscreen>
            <iconic>no</iconic>
            <layer>below</layer>
            <decor>no</decor>
            <maximized>true</maximized>
        </application>
EOF
    sed -i '/<applications>/r /tmp/rc.xml.applications' ~/.config/openbox/rc.xml
    rm /tmp/rc.xml.applications
    sed -e 's/<keepBorder>yes<\/keepBorder>/<keepBorder>no<\/keepBorder>/g' -i ~/.config/openbox/rc.xml
    chown -R $USER:$USER ~/.config
    echo -e "FINISHED hide_openbox_xwindows \n\n"
    sleep 2
}
# OpenBox autostarts unclutter, then passes off to the RetroPie autostart
mkdir -p ~/.config/openbox
echo 'unclutter -idle 0.01 -root' >> ~/.config/openbox/autostart
echo '/opt/retropie/configs/all/autostart.sh' >> ~/.config/openbox/autostart
chown -R $USER:$USER ~/.config
# Create RetroPie autostart
mkdir -p /opt/retropie/configs/all
touch /opt/retropie/configs/all/autostart.sh
chmod +x /opt/retropie/configs/all/autostart.sh
chown -R $USER:$USER /opt/retropie/configs

#create openbox autostart script for pegasus, which will start again if exited
echo "#!/bin/bash" >> ~/pegasus.sh
echo "while true; do" >> ~/pegasus.sh
echo "pegasus-fe" >> ~/pegasus.sh
echo "done" >> ~/pegasus.sh
chmod +x ~/pegasus.sh
echo 'gnome-terminal --full-screen --hide-menubar -- ~/pegasus.sh' >> /opt/retropie/configs/all/autostart.sh

#install kodi with rar support, user interaction required
echo Installing Kodi (with RAR support), please wait
sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install kodi kodi-vfs-rar
mkdir ~/RetroPie/roms/ports
echo "kodi-standalone" >> ~/RetroPie/roms/ports/Kodi.sh
chmod +x ~/RetroPie/roms/ports/Kodi.sh

#install Steam
echo Installing Steam, please wait
sudo apt-get install steam
echo "steam" >> ~/RetroPie/roms/ports/Steam.sh
chmod +x ~/RetroPie/roms/ports/Steam.sh

#installing requirements for Overcooked2
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade libstdc++6

#change audio to hdmi pulseaudio
sudo sed -i -e 's/set-default-sink output/set-default-sink output alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1/g' /etc/pulse/default.pa

#tips for retroarch 
echo "dont forget to edit retroarch with start pressed for 2 secs to enter menu"
echo ""
#tips on getting audio to work check https://wiki.archlinux.org/index.php/PulseAudio/Examples for more info 
echo "do pacmd list-sinks | grep -e 'name:' -e 'index:'"
echo "and ucomment the last line and set something like set-default-sink output alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1"
echo ""
echo ALL DONE!

I sourced the script from here. That poster said they preferred the Ubuntu 18.04 LTS mini.iso over the one from 20.04 LTS. Could that be my issue I am encountering?

I typed out the error messages from the second install as:

E: Failed to fetch https://dl.bintray.com/mmatyas/deb/dists/testing/InRelease  403  Forbidden [IP: 43.213.218.48 443]
E: The repository 'https://dl.bintray.com/mmatyas/deb testing InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8)  manpage for repository creation and user configuration details.
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package pegasus-frontend
retropie_installer.sh: 49: Syntax error: "(" unexpected

I discovered in the last attempt that there was a brownout for the server i question and is apparently fixed but when I removed the "()" in the script and was able to get further other issues came up that I did not capture last night being incredibly tired. What i noticed also is that this installer seems to get dependencies that somehow pulls in the Gnome Desktop. Is there any way to avoid this or prefer Mate where it currently grabs Gnome? I really don't even know why it's pulling Gnome at all because the eventual goal is to use openbox for what minimal desktop is needed.

Also an unfortunate side effect of the script results in my working WiFi stopping to work and no longer seeing any hotspots when prior to the install, the base command line system was working just fine with the WiFI. Not really sure why or how that is.

Thank you for reading this small book I've posted. I dearly hope that someone can help me accomplish what I'm trying to do here. Any assistance is appreciated!

EDIT: Just completed a try with the script as listed above and using the mini.iso for Ubuntu 18.04 LTS and can confirm that it makes no difference at all. It's something in the way the script is written that keeps tripping me up. Would dearly appreciate it if someone could read over and post an edit which will work. Seems to be a lot of syntax errors... Thanks in advance.

After eleven days and fifty-nine views, I feel it's probably safe to bump this in hopes of seeing a response from someone who can help. Does anyone know how to troubleshoot this installer script? Assistance is appreciated.

Line 49 complains about a parenthesis ... In bash, functions can be either defined using the reserved word function or without it. Remove the () in "function enable_autostart_xwindows () {" and try.

Re: "bash functions" one can define a function called this, with or without the word 'function'

this () { commands; }
or
function this { commands; }

1 Like

Thanks for the reply. Yeah I noted that another person had pointed out that bit, but as I said earlier:

but when I removed the "()" in the script and was able to get further other issues came up

This is why I'm trying to get someone who is willing to go through the whole script to help me eliminate all those. I don't know how to code a bash file so I don't know what is and isn't right. But the way this script installer is written you can only do it once. Then to try again you need to reinstall the command line system from the mini.iso and near the beginning of the script you have to build and install retropie from scratch, all of which takes a lot of time. I'd like to avoid redoing this over and over if I can.

I think I'm up to my sixth install now...

I looked at the errors again and read the forum.libreelec.tv post -- it seems this ip, 43.213.218.48 does not respond so fetching the repo will always fail ... E: Failed to fetch https://dl.bintray.com/mmatyas/deb/dists/testing/InRelease 403 Forbidden [IP: 43.213.218.48 443] I don't know if that repo moved somewhere else ... the whole site dl.bintray.com/ responds Forbidden !

2 Likes

So if I changed that bit from what it is to say...

#install pegasus fe / do this again from within retropie setup / experimental packages if scraped videos aren't working
curl https://github.com/mmatyas/pegasus-frontend/releases/download/continuous/pegasus-frontend_0.15.12_amd64.deb
sudo apt update
sudo apt install pegasus-frontend*.deb

Would that then allow me to go on and complete the installations? Obviously I'd need to change line also, but once that is done would I be able to complete the install assuming all other servers are still running?

That should work ... the logic is bypassing the dl.bintray repo and getting the pegasus-frontend.deb directly from github. If the script gets stuck further down, post and I will try to help ...

OK, just to be sure, this is the revision I will be using:

#! /bin/bash

#this setup script is brought to you by Northbane (c) 2020
#it is known to be very crude and simple 
#IMPORTANT: only run it once! or it will most likely fubar your os

#need to install deps for RetroPie and PegasusFE
sudo apt install menu python-xdg at-spi2-core pulseaudio alsa-utils libglib2.0-bin dbus-x11 triggerhappy git dialog unzip xmlstarlet x11-xserver-utils gstreamer1.0-alsa gstreamer1.0-libav gstreamer1.0-plugins-good jq policykit-1 curl xdg-utils -y

#manually install basic package in RetroPie or it wont work
cd ~
git clone --depth=1 https://github.com/RetroPie/RetroPie-Setup.git
cd RetroPie-Setup 
sudo ./retropie_setup.sh

#installing drivers if needed + openbox & lightdm
sudo apt install ubuntu-drivers-common software-properties-common curl lightdm openbox 
sudo ubuntu-drivers autoinstall

#disabling power saving mode
#echo "#turn off screen saver and power saving" >> ~/.profile
#echo "xset s off && xset -dpms" >> ~/.profile
sed -i '1 i\xset s off && xset -dpms' ~/.xsession


#add USB automount
#git clone https://github.com/rbrito/usbmount
#sudo apt install debhelper build-essential lockfile-progs
#cd usbmount
#dpkg-buildpackage -us -uc -b
#cd ~ && sudo dpkg -i usbmount*.deb

#create autologin for current user / deprecated?
#if [ ! -e "/etc/lightdm/lightdm.conf" ]; then
#echo "[SeatDefaults]" >> ~/lightdm.conf
#echo "autologin-user=$USER" >> ~/lightdm.conf
#echo "autologin-user-timeout=0" >> ~/lightdm.conf
#echo "user-session=openbox" >> ~/lightdm.conf
#sudo mv ~/lightdm.conf /etc/lightdm/
#fi

#install pegasus fe / do this again from within retropie setup / experimental packages if scraped videos aren't working

curl https://github.com/mmatyas/pegasus-frontend/releases/download/continuous/pegasus-frontend_0.15.12_amd64.deb
sudo apt update
sudo apt install pegasus-frontend*.deb

# Start X as soon as autologin is complete
function enable_autostart_xwindows {
    echo "--------------------------------------------------------------------------------"
    echo "| Enabling autostart of X Windows"
    echo "--------------------------------------------------------------------------------"
    # Create a .xsession file to launch OpenBox when startx is called
    echo 'exec openbox-session' >> ~/.xsession
    chown $USER:$USER ~/.xsession

    # Add startx to .bash_profile
    cat << EOF >> ~/.bash_profile
if [[ -z \$DISPLAY ]] && [[ \$(tty) = /dev/tty1 ]]; then
    exec startx -- >/dev/null 2>&1
fi
EOF
    chown $USER:$USER ~/.bash_profile
    echo -e "FINISHED enable_autostart_xwindows \n\n"
    sleep 2
}


#remove password from user sudoers. 
#if grep -q "$USER ALL=(ALL) NOPASSWD:ALL" "/etc/sudoers"; then
sudo sed -i -e '$a\$USER ALL=(ALL) NOPASSWD:ALL' /etc/sudoers
#remove user from sudo
sudo gpasswd -d $USER sudo

#set up custom plymouth:
cd ~
sudo apt-get install plymouth plymouth-themes plymouth-x11 -y
git clone --depth=1 https://github.com/HerbFargus/plymouth-themes.git tempthemes
sudo cp -r ~/tempthemes/. /usr/share/plymouth/themes/
rm -r -f tempthemes
sudo update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/retropie-pacman/retropie-pacman.plymouth 10
sudo update-alternatives --set default.plymouth /usr/share/plymouth/themes/retropie-pacman/retropie-pacman.plymouth
sudo update-initramfs -u
sudo cp /etc/default/grub /etc/default/grub.backup
sudo sed -i -e 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=2/g' /etc/default/grub
sudo sed -i -e 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="quiet splash"/g' /etc/default/grub
sudo update-grub

# Hide Openbox Windows and reduce visibility of terminal
function hide_openbox_windows() {
    echo "--------------------------------------------------------------------------------"
    echo "| Hiding window decorations in OpenBox"
    echo "--------------------------------------------------------------------------------"
    # Reduce the visibility of the gnome terminal by prepending these settings in the bash profile
    GNOME_TERMINAL_SETTINGS='dbus-launch gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/'

    cat << EOF >> ~/.bash_profile
$GNOME_TERMINAL_SETTINGS use-theme-colors false
$GNOME_TERMINAL_SETTINGS use-theme-transparency false
$GNOME_TERMINAL_SETTINGS foreground-color '#FFFFFF'
$GNOME_TERMINAL_SETTINGS background-color '#000000'
$GNOME_TERMINAL_SETTINGS cursor-blink-mode 'off'
$GNOME_TERMINAL_SETTINGS scrollbar-policy 'never'
$GNOME_TERMINAL_SETTINGS audible-bell 'false'
gsettings set org.gnome.Terminal.Legacy.Settings default-show-menubar false
EOF
    chown $USER:$USER ~/.bash_profile

    # Further reduce the visibility of windows (terminal) by modifying the OpenBox config
    mkdir -p ~/.config/openbox
    cp /etc/xdg/openbox/rc.xml ~/.config/openbox/rc.xml
    cat << EOF > /tmp/rc.xml.applications
        <application class="*">
            <fullscreen>yes</fullscreen>
            <iconic>no</iconic>
            <layer>below</layer>
            <decor>no</decor>
            <maximized>true</maximized>
        </application>
EOF
    sed -i '/<applications>/r /tmp/rc.xml.applications' ~/.config/openbox/rc.xml
    rm /tmp/rc.xml.applications
    sed -e 's/<keepBorder>yes<\/keepBorder>/<keepBorder>no<\/keepBorder>/g' -i ~/.config/openbox/rc.xml
    chown -R $USER:$USER ~/.config
    echo -e "FINISHED hide_openbox_xwindows \n\n"
    sleep 2
}
# OpenBox autostarts unclutter, then passes off to the RetroPie autostart
mkdir -p ~/.config/openbox
echo 'unclutter -idle 0.01 -root' >> ~/.config/openbox/autostart
echo '/opt/retropie/configs/all/autostart.sh' >> ~/.config/openbox/autostart
chown -R $USER:$USER ~/.config
# Create RetroPie autostart
mkdir -p /opt/retropie/configs/all
touch /opt/retropie/configs/all/autostart.sh
chmod +x /opt/retropie/configs/all/autostart.sh
chown -R $USER:$USER /opt/retropie/configs

#create openbox autostart script for pegasus, which will start again if exited
echo "#!/bin/bash" >> ~/pegasus.sh
echo "while true; do" >> ~/pegasus.sh
echo "pegasus-fe" >> ~/pegasus.sh
echo "done" >> ~/pegasus.sh
chmod +x ~/pegasus.sh
echo 'gnome-terminal --full-screen --hide-menubar -- ~/pegasus.sh' >> /opt/retropie/configs/all/autostart.sh

#install kodi with rar support, user interaction required
echo Installing Kodi (with RAR support), please wait
sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install kodi kodi-vfs-rar
mkdir ~/RetroPie/roms/ports
echo "kodi-standalone" >> ~/RetroPie/roms/ports/Kodi.sh
chmod +x ~/RetroPie/roms/ports/Kodi.sh

#install Steam
echo Installing Steam, please wait
sudo apt-get install steam
echo "steam" >> ~/RetroPie/roms/ports/Steam.sh
chmod +x ~/RetroPie/roms/ports/Steam.sh

#installing requirements for Overcooked2
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade libstdc++6

#change audio to hdmi pulseaudio
sudo sed -i -e 's/set-default-sink output/set-default-sink output alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1/g' /etc/pulse/default.pa

#tips for retroarch 
echo "dont forget to edit retroarch with start pressed for 2 secs to enter menu"
echo ""
#tips on getting audio to work check https://wiki.archlinux.org/index.php/PulseAudio/Examples for more info 
echo "do pacmd list-sinks | grep -e 'name:' -e 'index:'"
echo "and ucomment the last line and set something like set-default-sink output alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1"
echo ""
echo ALL DONE!

Does that look good? That gets the scripting error that both you and the friend on Discord noted and then changes the defunct server to be able to hopefully get the Pegasus front end from GitHub directly...

looks ok ... I will look in discord, wimpy's world, #user-chat channel

Kaboom.... :frowning:

Here's the exact script I used:

#! /bin/bash

#this setup script is brought to you by Northbane (c) 2020
#it is known to be very crude and simple 
#IMPORTANT: only run it once! or it will most likely fubar your os

#need to install deps for RetroPie and PegasusFE
sudo apt install menu python-xdg at-spi2-core pulseaudio alsa-utils libglib2.0-bin dbus-x11 triggerhappy git dialog unzip xmlstarlet x11-xserver-utils gstreamer1.0-alsa gstreamer1.0-libav gstreamer1.0-plugins-good jq policykit-1 curl xdg-utils -y

#manually install basic package in RetroPie or it wont work
cd ~
git clone --depth=1 https://github.com/RetroPie/RetroPie-Setup.git
cd RetroPie-Setup 
sudo ./retropie_setup.sh

#installing drivers if needed + openbox & lightdm
sudo apt install ubuntu-drivers-common software-properties-common curl lightdm openbox 
sudo ubuntu-drivers autoinstall

#disabling power saving mode
#echo "#turn off screen saver and power saving" >> ~/.profile
#echo "xset s off && xset -dpms" >> ~/.profile
sed -i '1 i\xset s off && xset -dpms' ~/.xsession


#add USB automount
#git clone https://github.com/rbrito/usbmount
#sudo apt install debhelper build-essential lockfile-progs
#cd usbmount
#dpkg-buildpackage -us -uc -b
#cd ~ && sudo dpkg -i usbmount*.deb

#create autologin for current user / deprecated?
#if [ ! -e "/etc/lightdm/lightdm.conf" ]; then
#echo "[SeatDefaults]" >> ~/lightdm.conf
#echo "autologin-user=$USER" >> ~/lightdm.conf
#echo "autologin-user-timeout=0" >> ~/lightdm.conf
#echo "user-session=openbox" >> ~/lightdm.conf
#sudo mv ~/lightdm.conf /etc/lightdm/
#fi

#install pegasus fe / do this again from within retropie setup / experimental packages if scraped videos aren't working
curl https://github.com/mmatyas/pegasus-frontend/releases/download/continuous/pegasus-frontend_0.15.12_amd64.deb
sudo apt update
sudo apt install pegasus-frontend*.deb

# Start X as soon as autologin is complete
function enable_autostart_xwindows {
    echo "--------------------------------------------------------------------------------"
    echo "| Enabling autostart of X Windows"
    echo "--------------------------------------------------------------------------------"
    # Create a .xsession file to launch OpenBox when startx is called
    echo 'exec openbox-session' >> ~/.xsession
    chown $USER:$USER ~/.xsession

    # Add startx to .bash_profile
    cat << EOF >> ~/.bash_profile
if [[ -z \$DISPLAY ]] && [[ \$(tty) = /dev/tty1 ]]; then
    exec startx -- >/dev/null 2>&1
fi
EOF
    chown $USER:$USER ~/.bash_profile
    echo -e "FINISHED enable_autostart_xwindows \n\n"
    sleep 2
}


#remove password from user sudoers. 
#if grep -q "$USER ALL=(ALL) NOPASSWD:ALL" "/etc/sudoers"; then
sudo sed -i -e '$a\$USER ALL=(ALL) NOPASSWD:ALL' /etc/sudoers
#remove user from sudo
sudo gpasswd -d $USER sudo

#set up custom plymouth:
cd ~
sudo apt-get install plymouth plymouth-themes plymouth-x11 -y
git clone --depth=1 https://github.com/HerbFargus/plymouth-themes.git tempthemes
sudo cp -r ~/tempthemes/. /usr/share/plymouth/themes/
rm -r -f tempthemes
sudo update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/retropie-pacman/retropie-pacman.plymouth 10
sudo update-alternatives --set default.plymouth /usr/share/plymouth/themes/retropie-pacman/retropie-pacman.plymouth
sudo update-initramfs -u
sudo cp /etc/default/grub /etc/default/grub.backup
sudo sed -i -e 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=2/g' /etc/default/grub
sudo sed -i -e 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="quiet splash"/g' /etc/default/grub
sudo update-grub

# Hide Openbox Windows and reduce visibility of terminal
function hide_openbox_windows {
    echo "--------------------------------------------------------------------------------"
    echo "| Hiding window decorations in OpenBox"
    echo "--------------------------------------------------------------------------------"
    # Reduce the visibility of the gnome terminal by prepending these settings in the bash profile
    GNOME_TERMINAL_SETTINGS='dbus-launch gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/'

    cat << EOF >> ~/.bash_profile
$GNOME_TERMINAL_SETTINGS use-theme-colors false
$GNOME_TERMINAL_SETTINGS use-theme-transparency false
$GNOME_TERMINAL_SETTINGS foreground-color '#FFFFFF'
$GNOME_TERMINAL_SETTINGS background-color '#000000'
$GNOME_TERMINAL_SETTINGS cursor-blink-mode 'off'
$GNOME_TERMINAL_SETTINGS scrollbar-policy 'never'
$GNOME_TERMINAL_SETTINGS audible-bell 'false'
gsettings set org.gnome.Terminal.Legacy.Settings default-show-menubar false
EOF
    chown $USER:$USER ~/.bash_profile

    # Further reduce the visibility of windows (terminal) by modifying the OpenBox config
    mkdir -p ~/.config/openbox
    cp /etc/xdg/openbox/rc.xml ~/.config/openbox/rc.xml
    cat << EOF > /tmp/rc.xml.applications
        <application class="*">
            <fullscreen>yes</fullscreen>
            <iconic>no</iconic>
            <layer>below</layer>
            <decor>no</decor>
            <maximized>true</maximized>
        </application>
EOF
    sed -i '/<applications>/r /tmp/rc.xml.applications' ~/.config/openbox/rc.xml
    rm /tmp/rc.xml.applications
    sed -e 's/<keepBorder>yes<\/keepBorder>/<keepBorder>no<\/keepBorder>/g' -i ~/.config/openbox/rc.xml
    chown -R $USER:$USER ~/.config
    echo -e "FINISHED hide_openbox_xwindows \n\n"
    sleep 2
}
# OpenBox autostarts unclutter, then passes off to the RetroPie autostart
mkdir -p ~/.config/openbox
echo 'unclutter -idle 0.01 -root' >> ~/.config/openbox/autostart
echo '/opt/retropie/configs/all/autostart.sh' >> ~/.config/openbox/autostart
chown -R $USER:$USER ~/.config
# Create RetroPie autostart
mkdir -p /opt/retropie/configs/all
touch /opt/retropie/configs/all/autostart.sh
chmod +x /opt/retropie/configs/all/autostart.sh
chown -R $USER:$USER /opt/retropie/configs

#create openbox autostart script for pegasus, which will start again if exited
echo "#!/bin/bash" >> ~/pegasus.sh
echo "while true; do" >> ~/pegasus.sh
echo "pegasus-fe" >> ~/pegasus.sh
echo "done" >> ~/pegasus.sh
chmod +x ~/pegasus.sh
echo 'gnome-terminal --full-screen --hide-menubar -- ~/pegasus.sh' >> /opt/retropie/configs/all/autostart.sh

#install kodi with rar support, user interaction required
echo Installing Kodi (with RAR support), please wait
sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install kodi kodi-vfs-rar
mkdir ~/RetroPie/roms/ports
echo "kodi-standalone" >> ~/RetroPie/roms/ports/Kodi.sh
chmod +x ~/RetroPie/roms/ports/Kodi.sh

#install Steam
echo Installing Steam, please wait
sudo apt-get install steam
echo "steam" >> ~/RetroPie/roms/ports/Steam.sh
chmod +x ~/RetroPie/roms/ports/Steam.sh

#installing requirements for Overcooked2
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade libstdc++6

#change audio to hdmi pulseaudio
sudo sed -i -e 's/set-default-sink output/set-default-sink output alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1/g' /etc/pulse/default.pa

#tips for retroarch 
echo "dont forget to edit retroarch with start pressed for 2 secs to enter menu"
echo ""
#tips on getting audio to work check https://wiki.archlinux.org/index.php/PulseAudio/Examples for more info 
echo "do pacmd list-sinks | grep -e 'name:' -e 'index:'"
echo "and ucomment the last line and set something like set-default-sink output alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1"
echo ""
echo ALL DONE! 

First the attempt to curl the deb of pegasus-fe failed. Then it died of a syntax error on line 65.

retropie_installer.sh: 65: retropie_installer.sh: Syntax error: "}" unexpected

I could probably download and save the pegasus-fe deb manually in the home directory so it will find and install it, the same way I manually copy over the script itself from a live session of Ubuntu-Mate, but the syntax error I'm not sure about how to fix other than just removing the offending symbol and moving on (again) but that's a real cargo-cult level of handling it. I have no idea of what it was intended for in the scripting or what it will do to remove it. Just 'monkey see, monkey remove' which I hate doing because I don't know if doing so will cause other issues down the flow of the script...

Help?
Screenshot

The screenshot shows it was unable to find pegasus_frontend.deb so maybe you need to prefix it with ./ meaning the current dir, eg. sudo apt install ./pegasus_frontend*.deb The previous line of curl probably brought in the deb file in the current dir.

Another issue I see is that you don't have a ~/.xsession file

Any suggestions on how to fix the ~/.xsession file?

That was part of why I went for the picture, I figured it'd be easier to troubleshoot and to make sure I hadn't missed anything. Also I really didn't want to type all that out. :laughing:

Also, as stated before I noticed a lot of the Gnome desktop seems to get pulled in when doing this. Any way to limit that or set it to prefer Mate desktop where needed? Really do not want Gnome.

Will change that section to read:

sudo apt install ./pegasus_frontend*.deb

Hopefully it will get me further down the road. Any ideas on the syntax error that halted things?

Are you testing this on um18.04 or um20.04? I can start a VM and try to test the script ...

I started with 20.04 LTS and then since the original guy said he used 18.04 LTS I tried that to determine if somehow the changes under the hood between versions may be what was causing my troubles. Am now currently preparing to install 20.04 LTS for another run at this because at least it's got a longer support window and using the older version did not seem to fix anything.

Do you have a preference?

EDIT: In case you need it, they moved the mini.iso for Focal. You can find it here.

I can use 20.04 -- although I dont have much time -- but I wrote earlier that I will try to help you.

You could create your own .xsession in your home dir and let sed insert options so before the sed line add, touch ~/.xsession This will create a file with zero bytes and sed will add options to it.

Ok, so that section looks like this now:

#disabling power saving mode
#echo "#turn off screen saver and power saving" >> ~/.profile
#echo "xset s off && xset -dpms" >> ~/.profile
touch ~/.xsession
sed -i '1 i\xset s off && xset -dpms' ~/.xsession

Thanks. I really do appreciate you helping me muddle through this. Any ideas on the syntax error or should I wait a bit before I make another go at the script?

the sed command does not look right. Replace with:

echo "xset s off && xset -dpms" > ~/.xsession

run the script again ... let's see where it will error out.

Will do, once the install of the base system finishes. This is all happening on a Lenovo ThinkCentre M73 Tiny with an i3...it takes a bit unfortunately. But it was cheap and generally works fine once stuff is loaded.

Just to be sure, before I go here is the revised installer script:

#! /bin/bash

#this setup script is brought to you by Northbane (c) 2020
#it is known to be very crude and simple 
#IMPORTANT: only run it once! or it will most likely fubar your os

#need to install deps for RetroPie and PegasusFE
sudo apt install menu python-xdg at-spi2-core pulseaudio alsa-utils libglib2.0-bin dbus-x11 triggerhappy git dialog unzip xmlstarlet x11-xserver-utils gstreamer1.0-alsa gstreamer1.0-libav gstreamer1.0-plugins-good jq policykit-1 curl xdg-utils -y

#manually install basic package in RetroPie or it wont work
cd ~
git clone --depth=1 https://github.com/RetroPie/RetroPie-Setup.git
cd RetroPie-Setup 
sudo ./retropie_setup.sh

#installing drivers if needed + openbox & lightdm
sudo apt install ubuntu-drivers-common software-properties-common curl lightdm openbox 
sudo ubuntu-drivers autoinstall

#disabling power saving mode
#echo "#turn off screen saver and power saving" >> ~/.profile
#echo "xset s off && xset -dpms" >> ~/.profile
touch ~/.xsession
echo "xset s off && xset -dpms" > ~/.xsession


#add USB automount
#git clone https://github.com/rbrito/usbmount
#sudo apt install debhelper build-essential lockfile-progs
#cd usbmount
#dpkg-buildpackage -us -uc -b
#cd ~ && sudo dpkg -i usbmount*.deb

#create autologin for current user / deprecated?
#if [ ! -e "/etc/lightdm/lightdm.conf" ]; then
#echo "[SeatDefaults]" >> ~/lightdm.conf
#echo "autologin-user=$USER" >> ~/lightdm.conf
#echo "autologin-user-timeout=0" >> ~/lightdm.conf
#echo "user-session=openbox" >> ~/lightdm.conf
#sudo mv ~/lightdm.conf /etc/lightdm/
#fi

#install pegasus fe / do this again from within retropie setup / experimental packages if scraped videos aren't working
curl https://github.com/mmatyas/pegasus-frontend/releases/download/continuous/pegasus-frontend_0.15.12_amd64.deb
sudo apt update
sudo apt install ./pegasus_frontend*.deb

# Start X as soon as autologin is complete
function enable_autostart_xwindows {
    echo "--------------------------------------------------------------------------------"
    echo "| Enabling autostart of X Windows"
    echo "--------------------------------------------------------------------------------"
    # Create a .xsession file to launch OpenBox when startx is called
    echo 'exec openbox-session' >> ~/.xsession
    chown $USER:$USER ~/.xsession

    # Add startx to .bash_profile
    cat << EOF >> ~/.bash_profile
if [[ -z \$DISPLAY ]] && [[ \$(tty) = /dev/tty1 ]]; then
    exec startx -- >/dev/null 2>&1
fi
EOF
    chown $USER:$USER ~/.bash_profile
    echo -e "FINISHED enable_autostart_xwindows \n\n"
    sleep 2
}


#remove password from user sudoers. 
#if grep -q "$USER ALL=(ALL) NOPASSWD:ALL" "/etc/sudoers"; then
sudo sed -i -e '$a\$USER ALL=(ALL) NOPASSWD:ALL' /etc/sudoers
#remove user from sudo
sudo gpasswd -d $USER sudo

#set up custom plymouth:
cd ~
sudo apt-get install plymouth plymouth-themes plymouth-x11 -y
git clone --depth=1 https://github.com/HerbFargus/plymouth-themes.git tempthemes
sudo cp -r ~/tempthemes/. /usr/share/plymouth/themes/
rm -r -f tempthemes
sudo update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/retropie-pacman/retropie-pacman.plymouth 10
sudo update-alternatives --set default.plymouth /usr/share/plymouth/themes/retropie-pacman/retropie-pacman.plymouth
sudo update-initramfs -u
sudo cp /etc/default/grub /etc/default/grub.backup
sudo sed -i -e 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=2/g' /etc/default/grub
sudo sed -i -e 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="quiet splash"/g' /etc/default/grub
sudo update-grub

# Hide Openbox Windows and reduce visibility of terminal
function hide_openbox_windows {
    echo "--------------------------------------------------------------------------------"
    echo "| Hiding window decorations in OpenBox"
    echo "--------------------------------------------------------------------------------"
    # Reduce the visibility of the gnome terminal by prepending these settings in the bash profile
    GNOME_TERMINAL_SETTINGS='dbus-launch gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/'

    cat << EOF >> ~/.bash_profile
$GNOME_TERMINAL_SETTINGS use-theme-colors false
$GNOME_TERMINAL_SETTINGS use-theme-transparency false
$GNOME_TERMINAL_SETTINGS foreground-color '#FFFFFF'
$GNOME_TERMINAL_SETTINGS background-color '#000000'
$GNOME_TERMINAL_SETTINGS cursor-blink-mode 'off'
$GNOME_TERMINAL_SETTINGS scrollbar-policy 'never'
$GNOME_TERMINAL_SETTINGS audible-bell 'false'
gsettings set org.gnome.Terminal.Legacy.Settings default-show-menubar false
EOF
    chown $USER:$USER ~/.bash_profile

    # Further reduce the visibility of windows (terminal) by modifying the OpenBox config
    mkdir -p ~/.config/openbox
    cp /etc/xdg/openbox/rc.xml ~/.config/openbox/rc.xml
    cat << EOF > /tmp/rc.xml.applications
        <application class="*">
            <fullscreen>yes</fullscreen>
            <iconic>no</iconic>
            <layer>below</layer>
            <decor>no</decor>
            <maximized>true</maximized>
        </application>
EOF
    sed -i '/<applications>/r /tmp/rc.xml.applications' ~/.config/openbox/rc.xml
    rm /tmp/rc.xml.applications
    sed -e 's/<keepBorder>yes<\/keepBorder>/<keepBorder>no<\/keepBorder>/g' -i ~/.config/openbox/rc.xml
    chown -R $USER:$USER ~/.config
    echo -e "FINISHED hide_openbox_xwindows \n\n"
    sleep 2
}
# OpenBox autostarts unclutter, then passes off to the RetroPie autostart
mkdir -p ~/.config/openbox
echo 'unclutter -idle 0.01 -root' >> ~/.config/openbox/autostart
echo '/opt/retropie/configs/all/autostart.sh' >> ~/.config/openbox/autostart
chown -R $USER:$USER ~/.config
# Create RetroPie autostart
mkdir -p /opt/retropie/configs/all
touch /opt/retropie/configs/all/autostart.sh
chmod +x /opt/retropie/configs/all/autostart.sh
chown -R $USER:$USER /opt/retropie/configs

#create openbox autostart script for pegasus, which will start again if exited
echo "#!/bin/bash" >> ~/pegasus.sh
echo "while true; do" >> ~/pegasus.sh
echo "pegasus-fe" >> ~/pegasus.sh
echo "done" >> ~/pegasus.sh
chmod +x ~/pegasus.sh
echo 'gnome-terminal --full-screen --hide-menubar -- ~/pegasus.sh' >> /opt/retropie/configs/all/autostart.sh

#install kodi with rar support, user interaction required
echo Installing Kodi (with RAR support), please wait
sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install kodi kodi-vfs-rar
mkdir ~/RetroPie/roms/ports
echo "kodi-standalone" >> ~/RetroPie/roms/ports/Kodi.sh
chmod +x ~/RetroPie/roms/ports/Kodi.sh

#install Steam
echo Installing Steam, please wait
sudo apt-get install steam
echo "steam" >> ~/RetroPie/roms/ports/Steam.sh
chmod +x ~/RetroPie/roms/ports/Steam.sh

#installing requirements for Overcooked2
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade libstdc++6

#change audio to hdmi pulseaudio
sudo sed -i -e 's/set-default-sink output/set-default-sink output alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1/g' /etc/pulse/default.pa

#tips for retroarch 
echo "dont forget to edit retroarch with start pressed for 2 secs to enter menu"
echo ""
#tips on getting audio to work check https://wiki.archlinux.org/index.php/PulseAudio/Examples for more info 
echo "do pacmd list-sinks | grep -e 'name:' -e 'index:'"
echo "and ucomment the last line and set something like set-default-sink output alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1"
echo ""
echo ALL DONE!

Could you take a look at line #66 and tell me if that should be there?

Line 66 seems to be the end of the function, right?

you an add set -e as the second line of the script (after #!/bin/bash) so that the script will stop if it errors out.

You can also remove the commended sections #add USB automount and # create autologin ... that's about 15 lines.

OK, script is running.

I added the set -e as second line in the script as instructed. I also noticed that I made a stupid when putting in the pegasus-frontend line so I fixed that. It was looking for pegasus_frontend when it needed pegasus-frontend. My mistake. I also manually transferred the deb so either way, I'm hoping it will work out.

I left the automount and autologin because I want those things to be working. This is intended to be basically a console once it's working with the option to go between Steam and emulated games and Kodi for media playback in one interface. If only there were a way to add Steam to LibreELEC I'd be trying to make a go with that...assuming I could figure out the build system, which is not guaranteed! :wink:

Thanks again for the assistance. Waiting for retropie to finish its bit now.