From 15f043c2c297176bd623d8a8602e2dc5d67eacd6 Mon Sep 17 00:00:00 2001 From: Ian Kelling 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 </etc/systemd/system/mailroute.service <