From 15f043c2c297176bd623d8a8602e2dc5d67eacd6 Mon Sep 17 00:00:00 2001 From: Ian Kelling <iank@fsf.org> Date: Fri, 9 Feb 2018 23:46:19 -0500 Subject: [PATCH] various fixes and improvements --- brc | 6 +- distro-begin | 2 +- distro-end | 307 ++++------------------------------- distro-pkgs | 262 ++++++++++++++++++++++++++++++ mail-setup | 16 +- pkgs | 14 +- radicale-setup | 15 +- subdir_files/.gnupg/gpg.conf | 1 + 8 files changed, 335 insertions(+), 288 deletions(-) create mode 100755 distro-pkgs diff --git a/brc b/brc index fbc1acb..96e66a8 100644 --- a/brc +++ b/brc @@ -951,6 +951,10 @@ else } fi +ipdrop() { + s iptables -A INPUT -s $1 -j DROP +} + net-dev-info() { e "lspci -nnk|gr -iA2 net" lspci -nnk|gr -iA2 net @@ -1527,7 +1531,7 @@ t() { declare -gi _seq; _seq+=1 echo "test body" | m mail -s "test mail from $HOSTNAME, $_seq" "${@:-root@localhost}" # for testing to send from an external address, you can do for example - # -aFrom:ian@iank.bid web-6fnbs@mail-tester.com + # -fian@iank.bid -aFrom:ian@iank.bid web-6fnbs@mail-tester.com # note in exim, you can retry a deferred message # s exim -M MSG_ID # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN diff --git a/distro-begin b/distro-begin index e77ff04..4c889b3 100755 --- a/distro-begin +++ b/distro-begin @@ -469,7 +469,7 @@ EOF fi ##### setup /nocow. -# a nocow dir that is common to multiple distros installed onthe same system +# a nocow dir that is common to multiple distros installed on the same system dir=/nocow if has_btrfs; then if ! mountpoint $dir; then diff --git a/distro-end b/distro-end index 660d556..9f06366 100755 --- a/distro-end +++ b/distro-end @@ -13,131 +13,67 @@ # See the License for the specific language governing permissions and # limitations under the License. +### setup errcatch +src="${BASH_SOURCE%/*}" +source $src/pkgs set -x - exec &> >(sudo tee -a /var/log/distro-end) echo "$0: $(date): starting now)" - -src="${BASH_SOURCE%/*}" - -source $src/pkgs - # see example of usage to understand. end_msg() { local y IFS= read -r -d '' y ||: end_msg_var+="$y" } - spa() { # simple package add simple_packages+=($@) } - distro=$(distro-name) - pending_reboot=false sed="sed --follow-symlinks" - # template case $distro in esac +#### initial packages pup if isdeb; then pi aptitude fi -simple_packages=(${p3[@]}) - -case $HOSTNAME in - lj|li) : ;; - *) - simple_packages+=(${p4[@]}) - spa $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') - ;; -esac - - ########### begin section including li ################ +pi ${p3[@]} $($src/distro-pkgs) conflink case $distro in - arch) - # ubuntu 14.04 uses b-cron, - # but its not maintained in arch. - # of the ones in the main repos, cronie is only one maintained. - # fcron appears abandoned software. - pi cronie - sgo cronie - ;; - *) : ;; # other distros come with cron. + arch) sgo cronie ;; esac - - case $distro in - *) pi at ;;& arch) sgo atd ;; esac case $distro in - debian|trisquel|ubuntu) pi curl;; - arch) : ;; - # fedora: unknown -esac - -case $distro in - # tk for gitk - arch) spa git tk ;; - *) spa git ;; -esac - -case $distro in - arch) spa the_silver_searcher ;; - debian|trisquel|ubuntu) spa silversearcher-ag ;; - # fedora unknown -esac - -case $distro in - debian|trisquel|ubuntu) spa ntp;; - arch) - pi ntp - sgo ntpd - ;; - # others unknown + arch) sgo ntpd ;; esac # no equivalent in other distros: case $distro in debian|trisquel|ubuntu) - pi aptitude if ! dpkg -s apt-file &>/dev/null; then # this condition is just a speed optimization pi apt-file s apt-file update fi - # for debconf-get-selections - spa debconf-utils ;; esac -case $distro in - arch|debian|trisquel|ubuntu) - spa bash-completion - ;; - # others unknown -esac - - - - - # disable motd junk. case $distro in debian) @@ -169,14 +105,8 @@ if isdebian; then setup-debian-auto-update fi -# we've got a few dependencies later on, so install them now. -pi eatmydata; PI_PREFIX=eatmydata -pi "${simple_packages[@]}" -simple_packages=() - ### begin docker install #### - if isdeb; then # https://store.docker.com/editions/community/docker-ce-server-debian?tab=description pi software-properties-common apt-transport-https @@ -249,7 +179,6 @@ esac # website setup case $HOSTNAME in lj|li) - case $HOSTNAME in lj) domain=iank.bid; exit 0 ;; li) domain=iankelling.org ;; @@ -622,28 +551,11 @@ EOF ;; esac - -# needed for checkrestart -if isdeb; then - spa debian-goodies -fi - - - ########### end section including li/lj ############### -case $distro in - debian) spa gnome-session-flashback ;; - # flidas is missing dependency gnome-panel. others unknown -esac - +pi ${p4[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') -case $distro in - trisquel|ubuntu|debian) spa ack-grep ;; - arch|fedora) spa ack ;; - # fedora unknown -esac @@ -661,20 +573,6 @@ EOF ;; esac -case $distro in - debian) - spa cpio-doc ;; - # not packaged in flidas. others unknown. gfdl nonfree issue -esac - - - - -case $distro in - fedora) spa unrar ;; - *) spa unrar-free ;; -esac - ### begin home vpn server setup @@ -717,6 +615,7 @@ fi if [[ $HOSTNAME == tp ]]; then + ##### rss2email # note, see bashrc for more documentation. pi rss2email s dd of=/etc/systemd/system/rss2email.service <<'EOF' @@ -749,6 +648,7 @@ EOF sgo rss2email.timer fi + ######### begin pump.io periodic backup ############# if [[ $HOSTNAME == frodo ]]; then s dd of=/etc/systemd/system/pumpbackup.service <<'EOF' @@ -776,6 +676,7 @@ EOF fi ######### end pump.io periodic backup ############# + case $distro in debian|trisquel|ubuntu) # suggests because we want the resolvconf package. however, i install it earlier @@ -802,9 +703,8 @@ lnf /a/opt/.AndroidStudio2.2 ~ spa lib32stdc++6 default-jdk +############# begin syncthing setup ########### if [[ $HOSTNAME == frodo ]]; then - ############# begin syncthing setup ########### - # It\'s simpler to just worry about running it in one place for now. # I assume it would work to clone it\'s config to another non-phone # and just run it in one place instead of the normal having a @@ -876,20 +776,11 @@ if [[ $HOSTNAME == frodo ]]; then # Note, the other thing i did was port forward port 22000, # per https://docs.syncthing.net/users/firewall.html - ############# end syncthing setup ########### fi +############# end syncthing setup ########### -# no equivalent in other distros: -case $distro in - debian|trisquel|ubuntu) - # for gui bug reporting - spa python-vte - ;; -esac - - ####### begin misc packages ########### reset-sakura @@ -1251,6 +1142,7 @@ EOF EOF done fi +######### end transmission client setup ###### # dunno why it\'s there, but get rid of it case $HOSTNAME in @@ -1258,7 +1150,7 @@ case $HOSTNAME in esac -# printer +### printer setup case $distro in arch) pi cups ghostscript gsfonts # from arch wiki cups page @@ -1281,66 +1173,7 @@ case $distro in trisquel|ubuntu|debian) pi --no-install-recommends mairix notmuch ;; fedora|arch) spa mairix notmuch ;; esac -case $distro in - arch) spa nfs-utils ;; - trisquel|ubuntu|debian) spa nfs-client ;; -esac -case $distro in - trisquel|ubuntu|debian) spa par2 ;; - arch|fedora) spa par2cmdline ;; -esac - -# needed for my tex resume -case $distro in - trisquel|ubuntu|debian) spa texlive-full ;; - arch) spa texlive-most ;; - # fedora unknown -esac - - -case $distro in - # optional dep for firefox for h.264 video - arch) spa gst-libav ;; - # other distros, probably come by default -esac -case $distro in - fedora|trisquel|ubuntu|debian) spa gnupg-agent ;; - arch) : ;; -esac - - -case $distro in - fedora) spa pinentry-gtk ;; - *) : ;; # comes default or with other packages -esac - -case $distro in - arch) spa firefox pulseaudio;; - trisquel) spa abrowser ;; - *) : ;; # comes default or with other packages, or uknown -esac - - -case $distro in - arch) spa ttf-dejavu;; - debian|trisquel|ubuntu) spa fonts-dejavu ;; - # others unknown -esac - - -case $distro in - arch) spa xorg-xev;; - debian|trisquel|ubuntu) spa x11-utils ;; - # others unknown -esac - -case $distro in - arch) pi virt-install;;& - debian|trisquel|ubuntu) pi virtinst ;;& - *) pi virt-manager ;; # creates the libvirt group in debian at least - # others unknown -esac # allow user to run vms, from debian handbook for x in iank traci; do s usermod -a -G libvirt,kvm $x; done # bridge networking as user fails. google lead here, but it doesn\'t work: @@ -1354,39 +1187,17 @@ for x in iank traci; do s usermod -a -G libvirt,kvm $x; done # #s chown root:qemu $f # debian has somethig like qemu-libvirt. equivalent? # s chmod 640 $f - -case $distro in - arch) spa cdrkit;; - debian|trisquel|ubuntu) spa genisoimage;; - # others unknown -esac - -case $distro in - arch) spa spice-gtk3 ;; - debian|trisquel|ubuntu) spa spice-client-gtk;; - # others unknown -esac - # general known for debian/ubuntu, not for fedora case $distro in debian|trisquel|ubuntu) - pi golang-go # a bit of googling, and added settings to bashrc go get -u github.com/mvdan/fdroidcl/cmd/fdroidcl ;; - # others unknown esac - case $distro in arch) - # cdrkit for cloud-init isos - # dnsmasq & ebtables for nat networking in libvirt - # qemu for qemu-img, bind-tools for dig - # dmidecode just because syslog complains - pi unzip xorg-xmodmap dmidecode ebtables\ - bridge-utils dnsmasq qemu bind-tools # otherwise we get error about accessing kvm module. # seems like there might be a better way, but google was a bit vague. s $sed -ri '/^ *user *=/d' /etc/libvirt/qemu.conf @@ -1397,41 +1208,9 @@ case $distro in # guessing this is not needed #sgo virtlogd.service sgo libvirtd - ;; esac -case $distro in - arch) pi virtviewer ;; - *) : ;; # other distros have it as a dependency afaik. -esac - - - -case $distro in - fedora) cabal install shellcheck ;; - *) spa shellcheck ;; - # unknown for older ubuntu -esac - - -case $distro in - arch|debian|trisquel|ubuntu) spa pumpa ;; - # others unknown. do have a buildscript: - # /a/bin/buildscripts/pumpa ;; -esac - - -case $distro in - debian) pi adb ;; - debian|trisquel|ubuntu) spa android-tools-adbd ;; - # todo: not sure this is needed anymore, or if trisqel etc works even - # debian) spa android-tools-adbd/unstable ;; - arch) spa android-tools ;; - # other distros unknown -esac - - case $distro in fedora) @@ -1457,28 +1236,6 @@ case $distro in esac -case $distro in - debian) - pi task-mate-desktop - # in settings, change scrolling to two-finger, - # because the default edge scroll doesn\'t work. - pu transmission-gtk - ;; - trisquel) - # mate-indicator-applet and beyond are msc things I noticed diffing a - # standard install with mine. - pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron - ;; - # others unknown -esac - -case $distro in - arch) spa apg ;; - # already in debian -esac - - - # note this failed running at the beginning of this file, @@ -1717,7 +1474,6 @@ esac # esac cd /a/opt/btrbk s make install -spa pv # for progress bar when running interactively. # ian: temporarily disabled while hosts are in flux. # if [[ $HOSTNAME == tp ]]; then @@ -1728,20 +1484,29 @@ spa pv # for progress bar when running interactively. # fi +end_msg <<'EOF' +In mate settings settings, change scrolling to two-finger, +because the default edge scroll doesn\'t work. Originally found this in debian. +EOF + +case $distro in + debian) + # remove dep that came in with desktop + pu transmission-gtk + ;; + esac case $distro in debian|trisquel|ubuntu) s gpasswd -a iank adm ;; #needed for reading logs esac -# tor +#### tor case $distro in # based on # https://www.torproject.org/docs/rpms.html.en # https://www.torproject.org/docs/debian.html.en # todo: figure out if the running service needs to be restarted upon updates - - # todo on fedora: setup non-dev packages fedora) s dd of=/etc/yum.repos.d/torproject.repo <<'EOF' @@ -1839,12 +1604,7 @@ fi e "$end_msg_var" -# persistent virtual machines -case $distro in - debian|trisquel|ubuntu) - pi libosinfo-bin; - ;; -esac + # if I was going to create a persistent vm, i might do it like this: # variant=something # from: virt-install --os-variant list # s virt-install --noautoconsole --graphics spice,listen=0.0.0.0 \ @@ -1856,17 +1616,6 @@ esac ######### begin stuff belonging at the end ########## -case $distro in - ubuntu|debian) - spa spacefm-gtk3 ;; - arch) - spa spacefm ;; -esac - - -pi "${simple_packages[@]}" - - if $pending_reboot; then echo "$0: pending reboot and then finished. doing it now." s reboot now diff --git a/distro-pkgs b/distro-pkgs new file mode 100755 index 0000000..0c137cb --- /dev/null +++ b/distro-pkgs @@ -0,0 +1,262 @@ +#!/bin/bash -l + +errcatch + + +usage() { + cat <<EOF +Usage: ${0##*/} [DISTRO_NAME] +Print packages to install for each distro. +Default DISTRO_NAME is the one currently running. + + +-h|--help Print help and exit. + +Note: Uses GNU getopt options parsing style +EOF + exit $1 +} + +if [[ $1 ]]; then + distro=$1 +else + distro=$(distro-name) +fi + +isdeb() { + case $distro in + debian|trisquel|ubuntu) + return 0 + ;; + esac + return 1 +} + +bool_opt=false # default +long_opt=foo # default +temp=$(getopt -l help,long-opt: hso: "$@") || usage 1 +eval set -- "$temp" +while true; do + case $1 in + -s) bool_opt=true; shift ;; + -o|--long-opt) long_opt="$2"; shift 2 ;; + -h|--help) usage ;; + --) shift; break ;; + *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;; + esac +done + + +case $distro in + arch) + # ubuntu 14.04 uses b-cron, + # but its not maintained in arch. + # of the ones in the main repos, cronie is only one maintained. + # fcron appears abandoned software. + e cronie + ;; + *) : ;; # other distros come with cron. +esac + +case $distro in + arch) e tk ;; + *) : ;; # other distros come with tk from git +esac + +case $distro in + arch) e the_silver_searcher ;; + debian|trisquel|ubuntu) e silversearcher-ag ;; + # fedora unknown +esac + +if isdeb; then + # for debconf-get-selections + e debconf-utils +fi + +# needed for checkrestart +if isdeb; then + e debian-goodies +fi + +###### quit now for li/lj +case $HOSTNAME in + lj|li) + exit 0 + ;; +esac + +case $distro in + debian) e gnome-session-flashback ;; + # flidas is missing dependency gnome-panel. others unknown +esac + +case $distro in + trisquel|ubuntu|debian) e ack-grep ;; + arch|fedora) e ack ;; + # fedora unknown +esac + +case $distro in + debian) + e cpio-doc ;; + # not packaged in flidas. in ubuntu it is in multiverse +esac + +case $distro in + fedora) e unrar ;; + *) e unrar-free ;; +esac + +case $distro in + debian|trisquel|ubuntu) + # for gui bug reporting + e python-vte + ;; + # no equivalent in other distros: +esac + +case $distro in + arch) e nfs-utils ;; + trisquel|ubuntu|debian) e nfs-client ;; +esac + +case $distro in + trisquel|ubuntu|debian) e par2 ;; + arch|fedora) e par2cmdline ;; +esac + +# needed for my tex resume +case $distro in + trisquel|ubuntu|debian) e texlive-full ;; + arch) e texlive-most ;; + # fedora unknown +esac + +case $distro in + # optional dep for firefox for h.264 video + arch) e gst-libav ;; + # other distros, probably come by default +esac + +case $distro in + fedora|trisquel|ubuntu|debian) e gnupg-agent ;; + arch) : ;; +esac + + +case $distro in + fedora) e pinentry-gtk ;; + *) : ;; # comes default or with other packages +esac + +case $distro in + arch) e firefox pulseaudio;; + trisquel) e abrowser ;; + *) : ;; # comes default or with other packages, or uknown +esac + + +case $distro in + arch) e ttf-dejavu;; + debian|trisquel|ubuntu) e fonts-dejavu ;; + # others unknown +esac + + +case $distro in + arch) e xorg-xev;; + debian|trisquel|ubuntu) e x11-utils ;; + # others unknown +esac + +case $distro in + arch) e virt-install;;& + debian|trisquel|ubuntu) e virtinst ;;& + *) e virt-manager ;; # creates the libvirt group in debian at least + # others unknown +esac + + + +case $distro in + arch) e cdrkit;; + debian|trisquel|ubuntu) e genisoimage;; + # others unknown +esac + +case $distro in + arch) e spice-gtk3 ;; + debian|trisquel|ubuntu) e spice-client-gtk;; + # others unknown +esac + +case $distro in + debian|trisquel|ubuntu) + # fdroidcl dependency + e golang-go + ;; + # others unknown +esac + + +### stuff brought in through deps in other distros +case $distro in + arch) + # for nat networking in libvirt + e ebtables + # dmidecode just because syslog complains + e dmidecode + e unzip xorg-xmodmap bridge-utils qemu virtviewer apg + # for dig + e bind-tools + ;; +esac + +case $distro in + fedora) cabal install shellcheck ;; + *) e shellcheck ;; + # unknown for older ubuntu +esac + +case $distro in + arch|debian|trisquel|ubuntu) e pumpa ;; + # others unknown. do have a buildscript: + # /a/bin/buildscripts/pumpa ;; +esac + +case $distro in + debian) e adb ;; + debian|trisquel|ubuntu) e android-tools-adbd ;; + # todo: not sure this is needed anymore, or if trisqel etc works even + # debian) e android-tools-adbd/unstable ;; + arch) e android-tools ;; + # other distros unknown +esac + +#### desktopy stuff +case $distro in + debian) + e task-mate-desktop + ;; + trisquel) + # mate-indicator-applet and beyond are msc things I noticed diffing a + # standard install with mine. + e xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron + ;; + # others unknown +esac + +case $distro in + debian|trisquel|ubuntu) + e libosinfo-bin; + ;; + # others unknown +esac + +case $distro in + ubuntu|debian) + e spacefm-gtk3 ;; + arch) + e spacefm ;; +esac diff --git a/mail-setup b/mail-setup index fdb4c21..b02da1e 100755 --- a/mail-setup +++ b/mail-setup @@ -28,12 +28,14 @@ Setup exim4 / postfix / dovecot The minimal assumption we have is that /etc/mailpass exists -I\'ve had problems with postfix on debian: +I've had problems with postfix on debian: on stretch, a startup ordering issue caused all mail to fail. postfix changed defaults to only use ipv6 dns, causing all my mail to fail. -I haven\'t gotten around to getting a non-debian exim +I haven't gotten around to getting a non-debian exim setup. + + -h|--help Print help and exit. EOF exit $1 @@ -289,8 +291,9 @@ else # begin exim. has debian specific stuff for now if [[ -e /p/c/filesystem ]]; then # to put the hostname in the known hosts - ssh -o StrictHostKeyChecking=no root@li.iankelling.org : - /a/exe/vpn-mk-client-cert -b mail -n mail li.iankelling.org + : + #ssh -o StrictHostKeyChecking=no root@li.iankelling.org : + #/a/exe/vpn-mk-client-cert -b mail -n mail li.iankelling.org fi cat >/etc/systemd/system/mailroute.service <<EOF @@ -413,7 +416,7 @@ OnCalendar=daily WantedBy=timers.target EOF systemctl daemon-reload - systemctl start mailcert + #systemctl start mailcert systemctl restart mailcert.timer systemctl enable mailcert.timer @@ -891,6 +894,9 @@ EOF done # end setup passwd.client + # by default, only 10 days of logs are kept. increase that. + sed -ri 's/^(\s*rotate\s).*/\11000/' /etc/logrotate.d/exim4-base + systemctl restart exim4 fi #### end if exim4 diff --git a/pkgs b/pkgs index 1c1ce85..4089472 100644 --- a/pkgs +++ b/pkgs @@ -1,5 +1,7 @@ #!/bin/bash # meant to be sourced +# +# packages with the same name across distros. p1=( trash-cli @@ -15,10 +17,16 @@ p2=( dmenu ) p3=( + at + bash-completion + curl + eatmydata + git htop iptables mailutils nmon + ntp rdiff-backup ruby ruby-rest-client @@ -34,12 +42,14 @@ p3=( # pidgin-otr, i went into pidgin pluggin settings and generated a key for some accounts # xawtv has webcam cli control. v4lctl bright 80%; v4lctl list # guvcview also adjusts webcam +# pv is used by btrbk p4=( adb apache2 apache2-doc apt-doc apt-listchanges + apt-rdepends aptitude-doc-en bash-doc beets @@ -87,7 +97,6 @@ p4=( libreoffice linphone linux-doc - locate lshw make-doc manpages @@ -114,6 +123,7 @@ p4=( pidgin pidgin-otr pry + pv python-autopep8 python3-doc qrencode @@ -138,3 +148,5 @@ p4=( xscreensaver-gl xscreensaver-gl-extra ) + +pall=(${p1[@]} ${p2[@]} ${p3[@]} ${p4[@]} ) diff --git a/radicale-setup b/radicale-setup index aed914b..929a14f 100755 --- a/radicale-setup +++ b/radicale-setup @@ -1,5 +1,5 @@ #!/bin/bash -l - +set -x [[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@" @@ -40,6 +40,19 @@ ser daemon-reload # not sure this is needed pi-nostart radicale +# use persistent uid/gid +IFS=:; read _ _ uid _ < <(getent passwd radicale ); unset IFS +IFS=:; read _ _ gid _ < <(getent group radicale ); unset IFS +if [[ $uid != 609 ]]; then + systemctl stop radicale ||: + usermod -u 609 radicale + groupmod -g 609 radicale + usermod -g 609 radicale +fi +find /o/radicale /var/log/radicale -xdev -exec chown -h 609 {} + +find /o/radicale -xdev -exec chgrp -h 609 {} + + + # I moved /var/lib/radicale after it's initialization. # I did a sudo -u radicale git init in the collections subfolder # after it gets created, per the git docs. diff --git a/subdir_files/.gnupg/gpg.conf b/subdir_files/.gnupg/gpg.conf index f9da1b5..3ddb9ff 100644 --- a/subdir_files/.gnupg/gpg.conf +++ b/subdir_files/.gnupg/gpg.conf @@ -6,6 +6,7 @@ keyserver-options auto-key-retrieve # start gpg agent on login use-agent + # standard short key ids are easy to collide # https://security.stackexchange.com/questions/84280/short-openpgp-key-ids-are-insecure-how-to-configure-gnupg-to-use-long-key-ids-i # https://evil32.com/ -- 2.30.2