From 5f97e1c4a592a6384a7a3d86f8ed337beb7e108f Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Fri, 12 Jul 2019 20:51:08 -0400 Subject: [PATCH] various improvements --- brc | 23 +-- distro-end | 285 ++++++++++--------------------- distro-pkgs | 233 ++++++++++++------------- i3-sway/common.conf | 40 +++-- mail-setup | 2 +- pkgs | 1 + subdir_files/.config/i3/config | 43 +++-- subdir_files/.config/sway/config | 43 +++-- subdir_files/.gnupg/gpg.conf | 7 +- xl | 15 ++ 10 files changed, 310 insertions(+), 382 deletions(-) create mode 100755 xl diff --git a/brc b/brc index 00200fe..1c1f0f8 100644 --- a/brc +++ b/brc @@ -1564,11 +1564,17 @@ stopnm() { ser stop dnsmasq s resolvconf -d NetworkManager ser start dnsmasq + s ifup br0 } startnm() { + s ifdown br0 ser start NetworkManager s nmtui-connect } +rebr() { + s ifdown br0 + s ifup br0 +} setini() { # set a value in a .ini style file key="$1" value="$2" section="$3" file="$4" @@ -2003,23 +2009,6 @@ wian() { wtr() { curl wttr.in/boston; } -xl() { - if pgrep gnome-screensav &>/dev/null; then - # this command actually starts gnome-screensaver if it isn\'t running. - # lololol, what crap - gnome-screensaver-command --exit &>/dev/null - fi - mate-screensaver-command --exit &>/dev/null - if ! pidof xscreensaver; then - pushd / - xscreensaver & - popd - # 1 was not long enough - sleep 3 - fi - xscreensaver-command -activate -} - xevkb() { xev -event keyboard; } # * misc stuff diff --git a/distro-end b/distro-end index 9d3f6f5..15ae5c2 100755 --- a/distro-end +++ b/distro-end @@ -27,10 +27,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,9 +47,31 @@ if isdeb; then pi aptitude fi +# avoid ptompts! +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 +105,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 +113,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 +120,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 +135,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 @@ -183,19 +184,20 @@ pi ${p1[@]} ##### begin automatic upgrades #### # this makes it so we upgrade everything -debconf-set-selections <<'EOF' +s debconf-set-selections <<'EOF' unattended-upgrades unattended-upgrades/origins_pattern string "codename=${distro_codename}"; EOF -dpkg-reconfigure -u -fnoninteractive unattended-upgrades +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' >/etc/cron.d/unattended-upgrade-reboot +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 @@ -207,7 +209,7 @@ web-conf -f 9100 -p 9101 apache2 $(hostname -f) <<'EOF' Require valid-user EOF - +fi # website setup case $HOSTNAME in @@ -606,6 +608,8 @@ esac ########### end section including li/lj ############### +# TODO: some of the X programs can be removed from pall when using wayland + # 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 @@ -1047,11 +1051,10 @@ EOF t=$(mktemp -d) cd $t aptitude download debootstrap/xenial - ex * + ex ./* s cp ./usr/share/debootstrap/scripts/* /usr/share/debootstrap/scripts - ;; - s dd of=/etc/apt/preferences.d/flidas-etiona <$t <$t < x.html -EOF - case $distro in trisquel|ubuntu|debian) @@ -1738,8 +1643,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 ;; @@ -1748,13 +1651,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' diff --git a/distro-pkgs b/distro-pkgs index 2267d8e..aded66a 100755 --- a/distro-pkgs +++ b/distro-pkgs @@ -4,7 +4,7 @@ err-catch usage() { - cat </dev/null; then + # this command actually starts gnome-screensaver if it isn\'t running. + # lololol, what crap + gnome-screensaver-command --exit &>/dev/null +fi +mate-screensaver-command --exit &>/dev/null +if ! pidof xscreensaver; then + pushd / + xscreensaver & + popd + # 1 was not long enough + sleep 3 +fi +xscreensaver-command -activate -- 2.30.2