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