Skip to content

Instantly share code, notes, and snippets.

@Ryan1729
Last active May 2, 2020 22:05
Show Gist options
  • Save Ryan1729/4dabf86ad7f37f95c1613d4551b71779 to your computer and use it in GitHub Desktop.
Save Ryan1729/4dabf86ad7f37f95c1613d4551b71779 to your computer and use it in GitHub Desktop.
alpine linux firefox box setup script
# This rest of this script assumes that you have recently installed alpine linux, and that you have already
# set up your own user account, and logged into it. Here's how you set up a user account if you would like to
# do that before continuing, (assumes you are logged in as root, and that you want to call your account "myuser").
# Parts of this section and the below ones are based on https://wiki.alpinelinux.org/wiki/Dwm
# adduser myuser
# apk add sudo nano
# You need to edit the /etc/sudoers file, to add a line for your user below the one for the root user in the
# "User priviledge specifications section". That is the lines should look someithing like:
# ##.
# ## User priviledge specifications
# ##
# root ALL=(ALL) ALL
# myuser ALL=(ALL) ALL
#
# It is recommened that you use `visudo` to edit the sudoers file, since that prevents saving
# if there are syntax errors etc. Nano should work too though.
#
# You can switch to your new user account with
# su myuser
# You'll probably want to follow that up with
# cd ~
# to get to your home directory.
# As of now, it seems like `wpa supplicant` just isn't setup to start automatically after an install.
# See https://gitlab.alpinelinux.org/alpine/aports/issues/8025
# So here's what you can do to set it up to automatically start:
# start up for now
# sudo rc-service wpa_supplicant start
# check with ping if you like
# ping -c 5 alpinelinux.org
# download this script (long url version)
# wget https://gist.githubusercontent.com/Ryan1729/4dabf86ad7f37f95c1613d4551b71779/raw/7f755ee7b1a330995369dde60bfbf53161e84864/firefox-setup.sh
# download this script (short url version)
# wget https://git.io/JvgNU
# then you can run it to get the rest set up.
die () {
echo $1; exit 1
}
test ! -e temp || die 'Temp file already exists. Move it so it does not get overwritten.'
#
# getting wifi working on next boot
#
sudo rc-update add wpa_supplicant default
# awk example came from here: https://stackoverflow.com/a/18276534
sudo awk '/need localmount/ { print; print "\tneed wpa_supplicant"; next }1' /etc/init.d/networking > temp; sudo cat temp > /etc/init.d/networking
sudo rc-update -u
#
# set up graphical environment for next boot
#
sudo setup-xorg-base
# We need to allow downloading from the community repositories, and the config for this is stored in
# the /etc/apk/repositories file. You just need to uncomment (remove the leading hashes from in this case)
# all the lines below the first one, to have access to all of the community repositories, incluing the
# bleeding edge ones. This script will allow all of them for you, but you can do this manually if you want
# to not use certain ones
sudo awk '/#h/ { print substr($1, 2, length($1)); next }1' /etc/apk/repositories > temp; sudo cat temp > /etc/apk/repositories
# tell apk we updated the repositories file
sudo apk update
sudo apk add firefox-esr ttf-dejavu i3wm dmenu i3status
# start i3 when x11 starts
echo "
exec i3" > ~/.xinitrc
echo '# Prepend the prompt with the return code of the last run command
export $PS1='"'"'\$? $PS1'"'"'
# start x11 when appropriate
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
startx
fi' > ~/.profile
# make firefox startup on boot
sudo awk '/bindsym XF86AudioMicMute/ { print; print "\n# This is a fox box\nexec firefox"; next }1' ~/.config/i3/config > temp; sudo cat temp > ~/.config/i3/config
@Ryan1729
Copy link
Author

Ryan1729 commented May 2, 2020

This might be improved by cribbing off of this Dockerfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment