X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=distro-end;h=84566b89fa4299468c147d69bd2e60ee97911166;hb=28904b44d0dd6ce9d43ab720b5efe9af2ce336de;hp=0e7c4b8197dab344b80a00602e76365deaa84dfa;hpb=45bb8be590318ef8f34df0d22aa9b54a83adc42e;p=distro-setup diff --git a/distro-end b/distro-end index 0e7c4b8..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,7 +121,7 @@ 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" @@ -126,36 +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 @@ -181,9 +183,22 @@ 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 #### -## prometheus node exporter setup -web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF' +# 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 @@ -195,7 +210,7 @@ web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF' Require valid-user EOF - +fi # website setup case $HOSTNAME in @@ -594,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 </dev/null <$t < x.html -EOF - case $distro in trisquel|ubuntu|debian) @@ -1661,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 ;; @@ -1671,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' @@ -1699,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 @@ -1770,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