X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=distro-end;h=18edaa56b8db4e3485e37f9d327acbdf62c40343;hb=7f759d320592e791a62cd0a966350e8c53ee0976;hp=61008fa66a44452ab84279cb2936e83463b586d0;hpb=5fc2a328a44bd7aac3110e7d9c49eaa3e0db8aaf;p=distro-setup diff --git a/distro-end b/distro-end index 61008fa..18edaa5 100755 --- a/distro-end +++ b/distro-end @@ -1,6 +1,7 @@ -#!/bin/bash -l +#!/bin/bash # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later +if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi ### setup source /a/bin/errhandle/err @@ -11,16 +12,14 @@ if [[ $EUID == 0 ]]; then exit 1 fi -_errcatch_cleanup() { +err-cleanup() { echo 1 >~/.local/distro-end } # shellcheck source=./pkgs source $src/pkgs -set -x -exec &> >(sudo tee -a /var/log/distro-end) -echo "$0: $(date): starting now)" +echo "$0: $(date) starting now)" # see example of usage to understand. end_msg() { local y @@ -32,26 +31,33 @@ end() { echo 0 >~/.local/distro-end if $pending_reboot; then echo "$0: pending reboot and then finished. doing it now." - s reboot now + echo "exiting with status 0" + sudo reboot now else echo "$0: $(date): ending now)" + echo "exiting with status 0" fi exit 0 } -die() { - printf "$0: %s\n" "$*" >&2; exit 1 +pre="${0##*/}:" +sudo() { + printf "$pre %s\n" "$*" + SUDOD="$PWD" command sudo "$@"; } -spa() { # simple package add - simple_packages+=($@) +sd() { + sudo dd of="$1" 2>/dev/null } +m() { printf "$pre %s\n" "$*"; "$@"; } +e() { printf "$pre %s\n" "$*"; } +err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $0: $*" >&2; } distro=$(distro-name) codename=$(debian-codename) codename_compat=$(debian-codename-compat) pending_reboot=false sed="sed --follow-symlinks" -# template -case $distro in -esac +## template: +# case $distro in +# esac #### initial packages pup @@ -60,7 +66,7 @@ if isdeb; then fi # avoid prompts -s debconf-set-selections </dev/null </dev/null </dev/null; then + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 + sd /etc/apt/preferences.d/flidas-bionic <$t </dev/null <<'EOF' -[Unit] -Description=ZNC, an advanced IRC bouncer -After=network-online.target - -[Service] -ExecStart=/usr/bin/znc -f --datadir=/var/lib/znc -User=znc - -[Install] -WantedBy=multi-user.target -EOF - ser daemon-reload - sgo znc + if ! getent passwd znc > /dev/null; then + sudo useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc + fi + sudo chmod 700 /var/lib/znc + sudo chown -R znc:znc /var/lib/znc + # Avoid restarting if possible, reconnecting to irc is annoying. + # The unit file was made active with conflink. + # Note, avoid using ser here because we wrap sudo to prints the command first. + if [[ $(systemctl is-active znc) != active ]]; then + sgo znc + fi ###### stop znc setup ##### end @@ -578,10 +604,23 @@ case $codename_compat in # mate doesnt have wayland support yet pi task-gnome-desktop ;; + bionic) + pi gnome-core + ;; esac +if [[ $codename_compat == flidas ]]; then + # doesnt exist in newer + pi gnupg-doc +fi +if [[ $codename == flidas ]]; then + pi abrowser +else + pi firefox + sudo ln -sf /usr/bin/firefox /usr/local/bin/abrowser +fi # TODO: some of the X programs can be removed from pall when using wayland @@ -592,11 +631,8 @@ esac pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $(apt-cache depends gcc|grep -i suggests:| awk '{print $2}') $($src/distro-pkgs) -sgo fsf-vpn-dns-cleanup - - # website is dead june 14 2019. back in october, but meh -s rm -f /etc/apt/sources.list.d/iridium-browser.list +sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list # case $distro in # debian) # pi chromium ;; @@ -639,13 +675,13 @@ s rm -f /etc/apt/sources.list.d/iridium-browser.list # done # key already exists, so this won't generate one, just the configs. -vpn-server-setup -rds -s tee -a /etc/openvpn/server/server.conf <<'EOF' +m vpn-server-setup -rds +sudo tee -a /etc/openvpn/server/server.conf <<'EOF' push "dhcp-option DNS 10.0.0.1" push "route 10.0.0.0 255.255.0.0" client-connect /a/bin/distro-setup/vpn-client-connect EOF -s sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf +sudo sed -i --follow-symlinks 's/10.8./10.9./g;s/^\s*port\s.*/port 1196/' /etc/openvpn/server/server.conf if [[ $HOSTNAME == tp ]]; then if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then @@ -661,7 +697,7 @@ fi ##### rss2email # note, see bashrc for more documentation. pi rss2email -s dd of=/etc/systemd/system/rss2email.service <<'EOF' +sd /etc/systemd/system/rss2email.service <<'EOF' [Unit] Description=rss2email After=multi-user.target @@ -674,7 +710,7 @@ Type=oneshot # we pass options to use different location. ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run EOF -s dd of=/etc/systemd/system/rss2email.timer <<'EOF' +sd /etc/systemd/system/rss2email.timer <<'EOF' [Unit] Description=rss2email @@ -687,12 +723,12 @@ OnUnitInactiveSec=300 [Install] WantedBy=timers.target EOF -s systemctl daemon-reload +sudo systemctl daemon-reload ######### begin pump.io periodic backup ############# if [[ $HOSTNAME == frodo ]]; then - s dd of=/etc/systemd/system/pumpbackup.service <<'EOF' + sd /etc/systemd/system/pumpbackup.service <<'EOF' [Unit] Description=pump li backup After=multi-user.target @@ -702,7 +738,7 @@ User=iank Type=oneshot ExecStart=/a/bin/log-quiet/sysd-mail-once pump-backup /a/bin/distro-setup/pump-backup EOF - s dd of=/etc/systemd/system/pumpbackup.timer <<'EOF' + sd /etc/systemd/system/pumpbackup.timer <<'EOF' [Unit] Description=pump li backup hourly @@ -712,7 +748,7 @@ OnCalendar=hourly [Install] WantedBy=timers.target EOF - s systemctl daemon-reload + ser daemon-reload sgo pumpbackup.timer fi ######### end pump.io periodic backup ############# @@ -720,7 +756,7 @@ fi ######### begin irc periodic backup ############# if [[ $HOSTNAME == frodo ]]; then - s dd of=/etc/systemd/system/ircbackup.service <<'EOF' + sd /etc/systemd/system/ircbackup.service <<'EOF' [Unit] Description=irc li backup After=multi-user.target @@ -730,7 +766,7 @@ User=iank Type=oneshot ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs EOF - s dd of=/etc/systemd/system/ircbackup.timer <<'EOF' + sd /etc/systemd/system/ircbackup.timer <<'EOF' [Unit] Description=irc li backup hourly @@ -740,7 +776,7 @@ OnCalendar=hourly [Install] WantedBy=timers.target EOF - s systemctl daemon-reload + sudo systemctl daemon-reload sgo ircbackup.timer fi @@ -748,10 +784,6 @@ fi ######### end irc periodic backup ############# -# https://github.com/jlebon/textern -cd /a/opt/textern -make native-install USER=1 - case $distro in debian|trisquel|ubuntu) # suggests resolvconf package. installing it here is redundant, but make sure anyways. @@ -763,7 +795,7 @@ case $distro in *) pi openvpn;; esac -/a/bin/distro-setup/radicale-setup +m /a/bin/distro-setup/radicale-setup ############# begin syncthing setup ########### @@ -783,12 +815,12 @@ if [[ $HOSTNAME == frodo ]]; then curl -s https://syncthing.net/release-key.txt | sudo apt-key add - s="deb http://apt.syncthing.net/ syncthing release" if [[ $(cat /etc/apt/sources.list.d/syncthing.list) != "$s" ]]; then - echo "$s" | s dd of=/etc/apt/sources.list.d/syncthing.list + echo "$s" | sd /etc/apt/sources.list.d/syncthing.list p update fi fi pi syncthing - lnf -T /w/syncthing /home/iank/.config/syncthing + m lnf -T /w/syncthing /home/iank/.config/syncthing ser daemon-reload # syncthing likely not properly packaged sgo syncthing@iank # runs as iank @@ -843,17 +875,17 @@ fi case $codename in flidas) - - ;; + : + ;; esac # sakura config is owned by ian -reset-sakura -reset-konsole -sudo -u user2 -i reset-konsole +m reset-sakura +m reset-konsole +m sudo -u user2 -i reset-konsole # user2 xscreensaver we don't want to reset -reset-xscreensaver +m reset-xscreensaver # this would install from cabal for newer / consistent version across os, but it screws up xmonad, so disabled for now. @@ -864,26 +896,26 @@ reset-xscreensaver # also, i assume syncing this between machines somehow messed thin #lnf -T /m/arbtt-capture.log ~/.arbtt/capture.log -primary-setup +m primary-setup if [[ ! -e ~/.linphonerc && -e /p/.linphonerc-initial ]]; then - cp /p/.linphonerc-initial ~/.linphonerc + m cp /p/.linphonerc-initial ~/.linphonerc fi ### begin spd install pi libswitch-perl libdigest-md5-file-perl libgnupg-interface-perl t=$(mktemp) -wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb -s dpkg -i $t -rm $t +m wget -O $t http://mirror.fsf.org/fsfsys-trisquel/fsfsys-trisquel/pool/main/s/spd-perl/spd-perl_0.2-1_amd64.deb +sudo dpkg -i $t +m rm $t # this guesses at the appropriate directory, adjust if needed perldir=(/usr/lib/x86_64-linux-gnu/perl/5.*) -sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]} +m sudo ln -sf ../../../perl/5.18.2/SPD/ ${perldir[0]} # newer distro had gpg2 as default, older one, flidas, need to make it that way gpgpath=$(which gpg2) if [[ $x ]]; then - s mkdir -p /usr/local/spdhackfix + sudo mkdir -p /usr/local/spdhackfix s lnf -T $gpgpath /usr/local/spdhackfix/gpg fi ### end spd install @@ -956,7 +988,7 @@ mkschroot() { fi apps=($@) d=/nocow/schroot/$n - s dd of=/etc/schroot/chroot.d/$n.conf < /dev/null; then - s groupadd -g 450 debian-transmission - s adduser --quiet \ - --gid 450 \ - --uid 450 \ - --system \ - --no-create-home \ - --disabled-password \ - --home /var/lib/transmission-daemon \ - debian-transmission + sudo groupadd -g 450 debian-transmission + sudo adduser --quiet \ + --gid 450 \ + --uid 450 \ + --system \ + --no-create-home \ + --disabled-password \ + --home /var/lib/transmission-daemon \ + debian-transmission fi # We want group writable stuff from transmission. # However, after setting this, I learn that transmission sets it's # own umask based on it's settings file. Well, no harm leaving this # so it's set right from the beginning. -s chfn debian-transmission -o umask=0002 +sudo chfn debian-transmission -o umask=0002 # note i had to do this, which is persistent: # cd /i/k @@ -1049,7 +1090,7 @@ tu /etc/sysctl.conf<<'EOF' net.core.rmem_max = 67108864 net.core.wmem_max = 16777216 EOF -s sysctl -p +sudo sysctl -p # some reason it doesn\'t seem to start automatically anyways pi-nostart transmission-daemon @@ -1062,17 +1103,17 @@ ser stop transmission-daemon # plus a simple symlink to the config file which it\'s # not worth separating out. # between comps, the uid can change -f=/i/transmission-daemon +f=$tdir/transmission-daemon +mkdir -p $f s lnf -T $f /var/lib/transmission-daemon/.config/transmission-daemon -if [[ -e $f ]]; then - s chown -R debian-transmission:debian-transmission $f -fi -for f in /i/k/partial-torrents /i/k/torrents; do +s lnf -T /etc/transmission-daemon/settings.json $f/settings.json +sudo chown -R debian-transmission:debian-transmission $f +for f in $tdir/partial-torrents $tdir/torrents; do if [[ -e $f ]]; then - s chown -R debian-transmission:user2 $f + sudo chown -R debian-transmission:user2 $f fi done -s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon +sudo chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon # # config file documented here, and it\'s the same config # for daemon vs client, so it\'s documented in the gui. @@ -1084,16 +1125,15 @@ s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon # # Changed the cache-size to 256 mb, reduces disk use. # It is a read & write cache. -# -s ruby <<'EOF' +sudo ruby < false, 'rpc-authentication-required' => false, -'incomplete-dir' => '/i/k/partial-torrents', +'incomplete-dir' => '$tdir/partial-torrents', 'incomplete-dir-enabled' => true, -'download-dir' => '/i/k/torrents', +'download-dir' => '$tdir/torrents', "speed-limit-up" => 800, "speed-limit-up-enabled" => true, "peer-port" => 61486, @@ -1112,7 +1152,7 @@ if [[ ! -e /lib/systemd/system/openvpn-client@.service ]]; then vpn_ser=openvpn fi -s dd of=/etc/systemd/system/transmission-daemon-nn.service </dev/null) || continue + if [[ ! $uid -ge 1000 ]]; then continue fi d=$f/.config/transmission-remote-gtk - s -u $u mkdir -p $d - s -u $u dd of=$d/config.json <