X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=distro-end;h=84566b89fa4299468c147d69bd2e60ee97911166;hb=c926b55471a48cbcd99607ce1e003da55211d166;hp=655ae7f4c19d68bf6f4aa1cb6c9ea25997f03b3b;hpb=0b6d44c7f3d567e0a26138509c8a24cb57c69b50;p=distro-setup diff --git a/distro-end b/distro-end index 655ae7f..84566b8 100755 --- a/distro-end +++ b/distro-end @@ -15,7 +15,8 @@ ### setup source /a/bin/errhandle/err -src="${BASH_SOURCE%/*}" +src="$(readlink -f -- "$BASH_SOURCE")"; src=${src%/*} # directory of this file + source $src/pkgs set -x @@ -27,10 +28,14 @@ end_msg() { IFS= read -r -d '' y ||: end_msg_var+="$y" } +die() { + printf "$0: %s\n" "$*" >&2; exit 1 +} spa() { # simple package add simple_packages+=($@) } distro=$(distro-name) +codename_compat=$(debian-codename-compat) pending_reboot=false sed="sed --follow-symlinks" # template @@ -43,8 +48,30 @@ if isdeb; then pi aptitude fi +# avoid ptompts! +s debconf-set-selections </dev/null; then - # this condition is just a speed optimization - pi apt-file - s apt-file update - fi - ;; -esac +if isdeb && ! dpkg -s -- "$@" | grep -Fx "Status: install ok installed" &> /dev/null; then + # this condition is just a speed optimization + pi apt-file + s apt-file update +fi + # disable motd junk. case $distro in @@ -82,10 +106,6 @@ case $distro in # this says disabling the service, it will still get restarted # but this script doesn't do anything on restart, so it should be fine s dd of=/var/run/motd.dynamic if=/dev/null - # stretch doesn't have initscripts pkg installed by default - if [[ $(debian-codename) == jessie ]]; then - s update-rc.d motd disable - fi ;; trisquel|ubuntu) # this isn't a complete solution. It still shows me when updates are available, @@ -94,16 +114,6 @@ case $distro in ;; esac -# automatic updates -# reference: -# https://debian-handbook.info/browse/stable/sect.regular-upgrades.html -# /etc/cron.daily/apt calls unattended-upgrades -# /usr/share/doc/unattended-upgrades# cat README.md -# /etc/apt/apt.conf.d/50unattended-upgrades -if isdebian; then - setup-debian-auto-update -fi - ### begin docker install #### if isdeb; then @@ -111,10 +121,10 @@ if isdeb; then pi software-properties-common apt-transport-https curl -fsSL https://download.docker.com/linux/$(distro-name-compat)/gpg | sudo apt-key add - url=https://download.docker.com/linux/$(distro-name-compat) - l="deb [arch=amd64] $url $(debian-codename-compat) stable" + l="deb [arch=amd64] $url $codename_compat stable" if ! grep -xFq "$l" /etc/apt/sources.list{,.d/*.list}; then - sudo add-apt-repository $l + sudo add-apt-repository "$l" p update fi # docker eats up a fair amount of cpu when doing nothing, so don't enable it unless @@ -126,35 +136,28 @@ if isdeb; then case $HOSTNAME in li|lj) sgo docker ;; esac - # other distros unknown fi ### end docker install #### + ### begin certbot install ### -case $distro in - debian) - # note, need python-certbot-nginx for nginx, but it depends on nginx, - # and I'm not installing nginx by default right now. - # note python-certbot-apache is in suggests, but so is a doc package that brought in xorg - if [[ $(debian-codename) == jessie ]]; then - pi -t jessie-backports certbot python-certbot-apache - else - pi certbot python-certbot-apache - fi - ;; - trisquel|ubuntu) - # not packaged in xenial or flidas - pi software-properties-common - l="deb http://ppa.launchpad.net/certbot/certbot/ubuntu xenial main" - if ! grep -xFq "$l" /etc/apt/sources.list{,.d/*.list}; then - s add-apt-repository -y ppa:certbot/certbot ||: - p update - fi - pi python-certbot-apache - ;; - # todo: other distros unknown -esac +if [[ $distro == debian ]]; then + # note, need python-certbot-nginx for nginx, but it depends on nginx, + # and I'm not installing nginx by default right now. + pi certbot python-certbot-apache +elif [[ $codename_compat == xenial ]]; then + # not packaged in xenial or flidas + pi software-properties-common + l="deb http://ppa.launchpad.net/certbot/certbot/ubuntu xenial main" + if ! grep -xFq "$l" /etc/apt/sources.list{,.d/*.list}; then + s add-apt-repository -y ppa:certbot/certbot ||: + p update + fi + pi python-certbot-apache +else + die "distro unknown for certbot" +fi # make a version of the certbot timer that emails me. x=/systemd/system/certbot $sed -r -f - /lib$x.timer <<'EOF' |s dd of=/etc${x}mail.timer @@ -180,6 +183,35 @@ sgo certbotmail.timer pi ${p1[@]} +##### begin automatic upgrades #### +# this makes it so we upgrade everything +s debconf-set-selections <<'EOF' +unattended-upgrades unattended-upgrades/origins_pattern string "codename=${distro_codename}"; +EOF +s dpkg-reconfigure -u -fnoninteractive unattended-upgrades + +# Setup daily reboots, so all unattended upgrades go into affect +# unattended upgrades happen at 6 am + rand(60 min). +echo '20 7 * * * root /usr/local/bin/zelous-unattended-reboot' | s dd of=/etc/cron.d/unattended-upgrade-reboot +##### end automatic upgrades #### + +# office is not exposed to internet yet +if [[ $(hostname -f) != *.office.fsf.org ]]; then + ## prometheus node exporter setup + web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF' +#https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype +# https://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication + + AllowOverride None + AuthType basic + AuthName "Authentication Required" + # setup one time, with root:www-data, 640 + AuthUserFile "/etc/prometheus-htpasswd" + Require valid-user + +EOF +fi + # website setup case $HOSTNAME in lj|li) @@ -577,11 +609,167 @@ esac ########### end section including li/lj ############### + +case $(debian-codename) in + # needed for debootstrap scripts for fai since fai requires debian + flidas) + curl http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg | s apt-key add - + s dd of=/etc/apt/preferences.d/flidas-xenial </dev/null <$t <$t <$t <$t <$t </dev/null <$t < /dev/null; then + s groupadd -g 450 debian-transmission case $distro in arch) - s groupadd -g 450 debian-transmission s useradd \ --system \ --create-home \ @@ -1106,7 +1245,6 @@ if ! getent passwd debian-transmission > /dev/null; then --gid 450 \ --uid 450 \ --system \ - --group \ --no-create-home \ --disabled-password \ --home /var/lib/transmission-daemon \ @@ -1153,7 +1291,7 @@ EOF fi for f in /i/k/partial-torrents /i/k/torrents; do if [[ -e $f ]]; then - s chown -R debian-transmission:traci $f + s chown -R debian-transmission:user2 $f fi done s chown -R debian-transmission:debian-transmission /var/lib/transmission-daemon @@ -1254,8 +1392,11 @@ EOF rpc_pass=$(

x.html -EOF - case $distro in trisquel|ubuntu|debian) @@ -1630,8 +1685,6 @@ EOF ;; esac -# note, for jessie, it depends on a higher version of btrfs-tools. -# # # disabled due to my patch being in btrbk # case $distro in # arch|debian|trisquel|ubuntu) pi btrbk ;; @@ -1640,13 +1693,9 @@ esac cd /a/opt/btrbk s make install -# ian: temporarily disabled while hosts are in flux. -# if [[ $HOSTNAME == tp ]]; then -# # backup/sync manually on others hosts for now. -# sgo btrbk.timer -# # note: to see when it was last run, -# # ser list-timers -# fi +sgo btrbk.timer +# note: to see when it was last run, +# ser list-timers end_msg <<'EOF' @@ -1668,6 +1717,28 @@ esac /a/bin/buildscripts/pithosfly + +# based on guix manual instructions, also added code to profile +pi nscd +if ! type -p guix >/dev/null; then + cd $(mktemp -d) + wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh + # added some stuff to envonment.sh for profile based on + # manual instructions + # wget https://sv.gnu.org/people/viewgpg.php?user_id=15145 -qO - | gpg --import - + # echo is to get past prompt + yes | sudo -E HOME=$HOME bash guix-install.sh || [[ $? == 141 ]] + guix install glibc-utf8-locales + guix package --install guile +fi + +# install rust. +curl https://sh.rustup.rs -sSf | bash -s -- -y +# todo: update this. updates in rust are stupidly complicate +if ! which rg &>/dev/null; then + cargo install ripgrep +fi + #### tor case $distro in # based on @@ -1739,16 +1810,12 @@ make sure to reload the firewall to load the persistent configuration EOF pi nfs-utils - sgo nfs-server ;; debian|trisquel|ubuntu) - pi nfs-server + pi-nostart nfs-server ;; arch) pi nfs-utils || pending_reboot=true - sgo rpcbind - # this failed until I rebooted - sgo nfs-server ;; esac