Skip to content

Instantly share code, notes, and snippets.

@davidmroth
Last active September 12, 2018 06:18
Show Gist options
  • Save davidmroth/1c35e618102701236c52929ae17c6c68 to your computer and use it in GitHub Desktop.
Save davidmroth/1c35e618102701236c52929ae17c6c68 to your computer and use it in GitHub Desktop.
RetroPie Ubuntu minimal (Remove unused packages and startup scripts)
#!/bin/bash
#Roms
#https://archive.org/details/MAME0.37b5_MAME2000_Reference_Set_Update_2_ROMs_Samples
echo 'datasource_list: [ None ]' | sudo -s tee /etc/cloud/cloud.cfg.d/90_dpkg.cfg
apt remove --purge cloud-init lxd snapd open-iscsi accountsservice lxcfs -y
apt install alsa-base alsa-utils pulseaudio
#LABEL=cloudimg-rootfs / ext4 defaults,data=writeback,noatime,nodiratime 0 0
#LABEL=system-boot /boot/firmware vfat defaults 0 1
#tmpfs /tmp tmpfs defaults,noatime,nosuid,size=100m 0 0
#tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=30m 0 0
#tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0
#tmpfs /var/run tmpfs defaults,noatime,nosuid,mode=0755,size=2m 0 0
#tmpfs /var/spool/mqueue tmpfs defaults,noatime,nosuid,mode=0700,gid=12,size=30m 0 0
#Udev Rules
echo 'SUBSYSTEM=="tty", KERNEL=="tty[1-6]", GROUP="tty", MODE="0660", OPTIONS="last_rule"' | tee /etc/udev/rules.d/99-retropie.rules
#Interactive script with Systemd - https://alan-mushi.github.io/2014/10/26/execute-an-interactive-script-at-boot-with-systemd.html
# emulationstation.service
cat >/etc/systemd/system/emulationstation.service << 'EOF'
[Unit]
Description=EmulationStation
After=getty.target
Wants=setup_retropie_env.service
[Service]
Type=simple
User=retropie
WorkingDirectory=~
ExecStart=/usr/bin/emulationstation
StandardInput=tty
TTYPath=/dev/tty3
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
Restart=on-failure
[Install]
WantedBy=graphical.target
'EOF'
sudo systemctl enable emulationstation
# setup_env.service
cat >/usr/bin/setup_retropie_env.service << 'EOF'
[Unit]
Description=Setup RetroPie Environment
After=getty.target
[Service]
Type=oneshot
ExecStart=/usr/bin/setup_retropie_environment.sh
[Install]
WantedBy=graphical.target
'EOF'
# setup_environment.sh
cat >/usr/bin/setup_environment.sh << 'EOF'
#!/bin/bash
# Assumes TTY3
echo "Setting up environment..."
# Create log dir if it does not exist
test -e /var/log/retropie || mkdir -p /var/log/retropie; chown retropie.retropie -R /var/log/retropie
ln -sf /opt/retropie/configs/all/emulationstation/es_log.txt /var/log/retropie/es_log.txt
ln -sf /opt/retropie/configs/all/emulationstation/es_log.txt /var/log/retropie/es_log.txt.bak
chvt 3
# Set resolution and output - Best: state 0x12000a [HDMI DMT (4) RGB full 4:3], 640x480 @ 60.00Hz, progressive
#tvservice -e "CEA 1 HDMI" # set resolution and output type - 640x480
#tvservice -p # set to preferred resolution
# Clear screen
printf '\e[3J' | sudo tee /dev/tty3
'EOF'
#https://github.com/RetroPie/RetroPie-Setup/wiki/Nintendo-64
#https://www.instructables.com/id/RetroPie-Overclocked-Raspberry-Pi-3-for-Video-Game/
echo "performance" |sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo mupen64plus_audio = "1" > /opt/retropie/configs/all/autoconf.cfg
#sudo vi /opt/retropie/configs/n64/mupen64plus.cfg
#https://github.com/retropie/retropie-setup/wiki/Overclocking
# Remove ttys
# https://www.thegeekdiary.com/centos-rhel-7-how-to-disable-all-tty-consoles-and-enable-only-1/
# Visudo
# retropie ALL=(root) NOPASSWD: /home/retropie/RetroPie-Setup/retropie_packages.sh
# Reload and restart RetroPie
sudo systemctl daemon-reload; sudo systemctl restart emulationstation
# Setup retropie user
usermod -a -G tty,dialout,cdrom,floppy,sudo,audio,dip,video,plugdev,input,netdev,lxd retropie
# Resolution Howto
#tvservice -m CEA # get supported resolutions
#tvservice -s # get current resolution
#tvservice -e "CEA 1 HDMI" # set resolution and output type
#tvservice -o # Trun off HDMI
#tvservice --sdtvon="NTSC 4:3" #set aspect
#Enable wifi
wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm/brcmfmac43430-sdio.bin
wget https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm/brcmfmac43430-sdio.txt
cp brcmfmac43430-sdio.* /lib/firmware/brcm/
modprobe -r brcmfmac
modprobe brcmfmac
# hostapd
# https://www.diyhobi.com/install-wifi-hotspot-raspberry-pi-ubuntu-mate/
#/etc/hostapd/hostapd.conf
cat >/etc/hostapd/hostapd.conf << 'EOF'
interface=wlan0
driver=nl80211
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
ssid=GAME_CONSOLE
wpa_passphrase=abc1234!
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment