X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=distro-end;h=14cc2f52ddca1ff5d0ea158f9d7d55e7734ba47f;hb=343a048be4b32d18540c6531048d2b9a006774ae;hp=c22e1130be39b67136dd60c5581f0776c1674771;hpb=4f13ea60bec1126f54b9da543b549d29d5013a69;p=distro-setup diff --git a/distro-end b/distro-end index c22e113..14cc2f5 100755 --- a/distro-end +++ b/distro-end @@ -15,7 +15,9 @@ ### setup source /a/bin/errhandle/err -src="${BASH_SOURCE%/*}" +src="$(readlink -f -- "${BASH_SOURCE[0]}")"; src=${src%/*} # directory of this file + +# shellcheck source=./pkgs source $src/pkgs set -x @@ -27,10 +29,15 @@ 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=$(debian-codename) +codename_compat=$(debian-codename-compat) pending_reboot=false sed="sed --follow-symlinks" # template @@ -43,8 +50,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 +108,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 +116,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 +123,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,35 +138,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 +185,58 @@ sgo certbotmail.timer pi ${p1[@]} +##### begin automatic upgrades #### + +s dd of=/etc/apt/apt.conf.d/10periodic <<'EOF' +# this file was mostly just comments. +APT::Periodic::Update-Package-Lists "1"; +APT::Periodic::Download-Upgradeable-Packages "1"; +APT::Periodic::AutocleanInterval "7"; +APT::Periodic::Unattended-Upgrade "1"; +EOF + +s dd of=/etc/apt/apt.conf.d/50unattended-upgrades < + 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) @@ -402,7 +459,7 @@ EOF # s reboot now # when running docker-compose run, kernel stack traces are printed to the journal. # things seem to succeed, google says nothing, so ignoring them. - curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` | s dd of=/usr/local/bin/docker-compose + curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-$(uname -s)-$(uname -m) | s dd of=/usr/local/bin/docker-compose s chmod +x /usr/local/bin/docker-compose @@ -444,7 +501,7 @@ EOF printf "%s=%s\n" $key "$(docker-compose run --rm web rake secret|dos2unix|tail -n1)" >>.env.production done found=false - while read -r domain port pass; do + while read -r domain _ pass; do if [[ $domain == mail.iankelling.org ]]; then found=true # remove the username part @@ -577,42 +634,215 @@ esac ########### end section including li/lj ############### -# depends gcc is a way to install suggests. this is apparently the only -# way to install suggests even if the main package is already -# installed. reinstall doesn't work, uninstalling can cause removing -# dependent packages. -pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $(apt-cache depends gcc|grep -i suggests:| awk '{print $2}') -if ! type pip; then - x=$(mktemp) - wget -O$x https://bootstrap.pypa.io/get-pip.py - python3 $x --user -fi +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 </dev/null <$t < x.html -EOF - case $distro in trisquel|ubuntu|debian) @@ -1629,8 +1732,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 ;; @@ -1639,13 +1740,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' @@ -1667,6 +1764,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 @@ -1738,16 +1857,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