home · contact · privacy
Upgrade Raspi setup.
[config] / buster / setup_scripts / setup_desktop.sh
1 #!/bin/sh
2 set -e
3
4 if [ "$#" -ne 1 ]; then
5     echo 'Need exactly one argument (system name).'
6     false
7 fi
8 if [ ! "$1" = "eeepc" ] && [ ! "$1" = "x200s" ] && [ ! "$1" = "x220" ] && [ ! "$1" = "w530" ]; then
9     echo "Need legal system name."
10     false
11 fi
12 system_name="$1"
13
14 # Set up system without user environment.
15 config_tree_prefix="${HOME}/config/buster"
16 setup_scripts_dir="${config_tree_prefix}/setup_scripts"
17 cd "${setup_scripts_dir}"
18 if [ "$1" = "x200s" ] || [ "$1" = "x220" ] || [ "$1" = "w530" ]; then
19   ./setup.sh "${system_name}" "" user desktop thinkpad "${system_name}"
20 else
21   ./setup.sh "${system_name}" "" user desktop "${system_name}"
22 fi
23 # For hibernation on lid switch to work, we need a newer kernel on the EeePC,
24 # see <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=919227>.
25 if [ "${system_name}" = "eeepc" ]; then
26     apt -y install -t buster-backports linux-image-amd64
27 fi
28
29 # Set up printer.
30 lpadmin -p 'HP_Deskjet_F300_series' -m 'drv:///hpcups.drv/hp-deskjet_f300_series.ppd' -o 'OutputMode=NormalGray' -E
31 service cups restart
32
33 # Install Firefox directly from Mozilla.
34 firefox_release="68.4.1esr"
35 firefox_filename="firefox-${firefox_release}.tar.bz2"
36 url_firefox="https://ftp.mozilla.org/pub/firefox/releases/${firefox_release}/linux-x86_64/en-US/${firefox_filename}"
37 wget "${url_firefox}"
38 mv "${firefox_filename}" /opt/
39 cd /opt/
40 tar xf "${firefox_filename}"
41 rm "${firefox_filename}"
42 ln -s /opt/firefox/firefox /usr/local/bin/
43 update-alternatives --install /usr/bin/x-www-browser x-www-browser /opt/firefox/firefox 200
44 update-alternatives --set x-www-browser /opt/firefox/firefox
45
46 # Install Firefox plugins.
47 # See <https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Distribution_options/Sideloading_add-ons>
48 extensions_dir="/usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/"
49 mkdir -p "${extensions_dir}"
50 umatrix_version="1.4.0"
51 umatrix_xpi="uMatrix.firefox.xpi"
52 url_umatrix="https://github.com/gorhill/uMatrix/releases/download/${umatrix_version}/${umatrix_xpi}"
53 wget "${url_umatrix}"
54 name=$(unzip -p "${umatrix_xpi}" manifest.json | jq -r .applications.gecko.id)
55 mv "${umatrix_xpi}" "${name}".xpi
56 tridactyl_version="1.17.1pre3355"
57 tridactyl_xpi="tridactyl_beta-${tridactyl_version}-an+fx.xpi"
58 url_tridactyl="https://tridactyl.cmcaine.co.uk/betas/${tridactyl_xpi}"
59 wget "${url_tridactyl}"
60 name=$(unzip -p "${tridactyl_xpi}" manifest.json | jq -r .applications.gecko.id)
61 mv "${tridactyl_xpi}" "${name}.xpi"
62 mv *.xpi "${extensions_dir}"
63
64 # Set up user environments.
65 secrets_dev="sdb"
66 source_dir_secrets="/media/${secrets_dev}/to_usb"
67 target_dir_secrets="/home/plom/tmp_secrets"
68 cd "${setup_scripts_dir}"
69 ./copy_dirtree.sh "${config_tree_prefix}/home_files" "/root" minimal root
70 set +e
71 HOME_DIR_EXISTS=$([ ! -d "/home/plom" ]; echo $?)
72 set -e
73 adduser --disabled-password --gecos "" plom
74 usermod -a -G sudo plom
75 passwd plom
76 if [ "${HOME_DIR_EXISTS}" -eq 0 ]; then
77     echo "Put secrets drive into slot for /dev/${secrets_dev}."
78     while [ ! -e /dev/"${secrets_dev}" ]; do
79         sleep 1
80     done
81     stty -echo
82     printf "Secrets passphrase: "
83     read secrets_pass
84     stty echo
85     echo "" # newline so user knows their input return was accepted
86     echo "${secrets_pass}" | pmount /dev/"${secrets_dev}"
87     cp -a "${source_dir_secrets}" "${target_dir_secrets}"
88     chown -R plom:plom "${target_dir_secrets}"
89     pumount "${secrets_dev}"
90     echo "You can remove /dev/${secrets_dev} now."
91     cp setup_home.sh /home/plom
92     chown plom:plom /home/plom/setup_home.sh
93     SECRETS_PASS="${secrets_pass}" su -c "cd && ./setup_home.sh ${system_name}" plom
94 fi