From f7a2fe0e56e14b55818245a2e3a2eb68f1cd23de Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sun, 28 Jan 2018 14:37:49 -0500 Subject: [PATCH] organize / cleanup --- btrbk-run | 2 +- distro-begin | 210 +++++++++++++++++++++++--------------------- mail-setup | 7 ++ mount-latest-subvol | 6 +- pkgs | 4 +- 5 files changed, 127 insertions(+), 102 deletions(-) diff --git a/btrbk-run b/btrbk-run index 5ff8326..a1c6963 100755 --- a/btrbk-run +++ b/btrbk-run @@ -81,7 +81,7 @@ echo -e "$0: options: conf_only=$conf_only\ndry_run=$dry_run\nresume_arg=$resume # set default targets if [[ ! -v targets ]]; then case $HOSTNAME in - x2|fz) + x2|kw) if [[ $HOSTNAME == "$MAIL_HOST" ]]; then targets=($HOME_DOMAIN) fi diff --git a/distro-begin b/distro-begin index 6ce91c4..e77ff04 100755 --- a/distro-begin +++ b/distro-begin @@ -323,37 +323,62 @@ if has_p; then lnf -T /i/k/mboxes ~/mail fi -### begin setup for keyboard and redshift ### -case $(distro-name) in - trisquel|ubuntu|debian) - if has_x; then + + + +##### install xinput +if has_x; then + case $(distro-name) in + trisquel|ubuntu|debian) pi xinput + ;; + fedora) + pi xinput_calibrator + ;; + arch) + pi xorg-xinput + ;; + esac + + #### install redshift + case $(distro-name) in + trisquel|ubuntu|debian) # recommends gets us geoclue (for darkening automatically at night i assume), # which recommends modemmanager, which is annoying to fix for the model01 keyboard. pi --no-install-recommends gtk-redshift - fi - ;;& - fedora) - p -y groupinstall development-tools c-development books admin-tools - pi wget man-pages - if has_x; then + ;;& + fedora) pi redshift-gtk - fi - ;;& + ;;& + arch) + pi redshift + ;;& + esac +fi + + +#### arch specific early packages +case $(distro-name) in arch) - # like apt-cache + # pkgfile is like apt-cache pi pkgfile s pkgfile --update - if has_x; then - pi xorg-server redshift xorg-xinput - fi - ;;& + ;; esac -### end setup for keyboard and redshift ### -# enables trim for volume delete, other rare commands. -sudo $sed -ri 's/( *issue_discards\b).*/\1 = 1/' /etc/lvm/lvm.conf +#### fedora specific packages +case $(distro-name) in + fedora) + # todo, this could probably come later + p -y groupinstall development-tools c-development books admin-tools + pi man-pages + ;; + # other distros unknown +esac +#### enable trim +# enable trim for volume delete, other rare commands +sudo $sed -ri 's/( *issue_discards\b).*/\1 = 1/' /etc/lvm/lvm.conf if encrypted; then if isdeb; then sudo cp /usr/share/doc/util-linux/examples/fstrim.{service,timer} /etc/systemd/system @@ -362,22 +387,20 @@ if encrypted; then sudo systemctl enable fstrim.timer fi +##### make extra dirs dirs=(/mnt/{1,2,3,4,5,6,7,8,9} /nocow/t) s mkdir -p "${dirs[@]}" s chown $USER:$USER "${dirs[@]}" - +###### setup /i tu /etc/fstab <<'EOF' /i/w /w none bind,noauto 0 0 /i/k /k none bind,noauto 0 0 EOF - - if ! mountpoint /kr; then s mkdir -p /kr s chown $USER:traci /kr fi - if home_network; then if [[ $HOSTNAME == frodo ]]; then tu /etc/fstab <<'EOF' @@ -389,17 +412,14 @@ frodo:/k /kr nfs noauto 0 0 EOF fi fi - s mkdir -p /q /i/{w,k} for dir in /{i,w,k}; do if mountpoint $dir; then continue; fi # already mounted s mkdir -p $dir s chown $USER:$USER $dir done - # not needed for all hosts, but rather just keep it uniform s mkdir -p /mnt/iroot - # debian auto mounting of multi-disk encrypted btrfs is busted. It is # in jessie, and in stretch as of 11/26/2016 I have 4 disks in cryptab, # based on 3 of those, it creates .device units for /dev/mapper/dev... @@ -448,6 +468,8 @@ EOF sudo systemctl start imount.service fi +##### setup /nocow. +# a nocow dir that is common to multiple distros installed onthe same system dir=/nocow if has_btrfs; then if ! mountpoint $dir; then @@ -470,14 +492,8 @@ else sudo mkdir -p $dir fi -# ssh and probably some other things care about parent directory -# ownership, and ssh doesn\'t allow any group writable parent -# directories, so we are forced to use a directory structure similar -# to home directories -s chown root:$USER /q -s chmod 755 /q - +###### fix mouse on jessie # it comes with stretch and arch, but not jessie. # propogate /etc/udev/hwdb.d if which systemd-hwdb; then @@ -486,24 +502,21 @@ if which systemd-hwdb; then fi +##### setup email if isdeb; then - # 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. - # exim4 is default on debian, so I assume it would - # be packaged better to avoid these types of things. - # I haven\'t gotten around to getting a non-debian exim - # setup. mail-setup exim4 else + # todo: probably broken mail-setup postfix fi +#### ubuntu nicety if isubuntu; then # disable crash report annoying dialogs. s dd of=/etc/default/apport <<<'enabled=0' fi +###### setup time zone # fai sets this an old way that doesn't work for stretch. # no harm in setting it universally here. # using debconf-set-selection, the area gets reset to ETC @@ -529,21 +542,16 @@ exit EOF +##### install emacs if has_x; then if isarch; then - # install so it's build dependencies don't get removed. - - # emacs git build is currently broken - if false; then - x=$(mktemp -d) - pushd $x - aurex emacs-git - makepkg -si --noconfirm - popd - rm -rf $x - else - pi emacs - fi + # emacs git build was broken last time i checked, + x=$(mktemp -d) + pushd $x + aurex emacs-git + makepkg -si --noconfirm + popd + rm -rf $x pi hunspell hunspell-en else if $recompile; then @@ -552,41 +560,42 @@ if has_x; then /a/bin/buildscripts/emacs --no-r || /a/bin/buildscripts/emacs fi fi +fi - # todo, figure this out for arch if we ever try out gnome. - if ! isarch; then - # install for multiple display managers in case we use one - if isdeb; then - dir=/etc/gdm3 - elif isfedora; then - # fedora didn\'t have the 3. - dir=/etc/gdm - fi - s mkdir -p $dir/PostLogin - s command cp /a/bin/distro-setup/desktop-20-autostart.sh $dir/PostLogin/Default - s mkdir /etc/lightdm/lightdm.conf.d - s dd of=/etc/lightdm/lightdm.conf.d/12-iank.conf <<'EOF' -[SeatDefaults] -session-setup-script=/a/bin/distro-setup/desktop-20-autostart.sh -EOF - fi +##### install laptop hardware packages +if tp || x2; then + case $distro in + debian) + pi task-laptop + ;; + ubuntu|trisquel) + # the exact packages that task-laptop would install, since ubuntu + # doesn\'t have this virtual in practice package. + pi avahi-autoipd bluetooth powertop iw wireless-tools wpasupplicant + ;; + # todo: other distros unknown + esac +fi +##### install xmonad +if has_x; then pi ${p2[@]} - # todo, also note for work comp, scp opt/org-mode bin/build-scripts - - # use the package manger version to install the cabal version - cabal update - PATH="$PATH:$HOME/.cabal/bin" - - # todo, on older ubuntu I used cabal xmonad + xfce, - # see /a/bin/old-unused/xmonad-cabal.sh - + # note: on older ubuntu I used cabal xmonad + xfce, using cabal versin + # see /w/archive/programming/xmonad-cabal.sh if isarch; then - # for displaying error messages. + # xorg-xmessage for displaying error messages. # optional dependency in arch, standard elsewhere. - pi xorg-xmessage xmonad-contrib xorg-xsetroot xorg-xinit + pi xorg-server xorg-xmessage xmonad-contrib xorg-xsetroot xorg-xinit + else + pi suckless-tools + fi +fi + +##### setup X autostart +if has_x; then + if isarch; then # https://wiki.archlinux.org/index.php/Xinitrc for homedir in /home/*; do cp /etc/X11/xinit/xinitrc $homedir/.xinitrc @@ -597,27 +606,30 @@ xsetroot -cursor_name left_ptr exec xmonad EOF done - else - pi suckless-tools - fi - pi dmenu - - if tp || x2; then - case $distro in - debian) - pi task-laptop - ;; - ubuntu|trisquel) - # the exact packages that task-laptop would install, since ubuntu - # doesn\'t have this virtual in practice package. - pi avahi-autoipd bluetooth powertop iw wireless-tools wpasupplicant - ;; - # todo: other distros unknown - esac + else + # todo, figure this out for arch if we ever try out gnome. + # install for multiple display managers in case we use one + if isdeb; then + dir=/etc/gdm3 + elif isfedora; then + # fedora didn\'t have the 3. + dir=/etc/gdm + fi + s mkdir -p $dir/PostLogin + s command cp /a/bin/distro-setup/desktop-20-autostart.sh $dir/PostLogin/Default + s mkdir /etc/lightdm/lightdm.conf.d + s dd of=/etc/lightdm/lightdm.conf.d/12-iank.conf <<'EOF' +[SeatDefaults] +session-setup-script=/a/bin/distro-setup/desktop-20-autostart.sh +EOF fi fi + +#### refix interactive ssh terminal # the first pup command can kill off our /etc/ mod, so rerun this /a/exe/ssh-emacs-setup + + echo "$0: $(date): ending now" exit 0 diff --git a/mail-setup b/mail-setup index c7f2933..fdb4c21 100755 --- a/mail-setup +++ b/mail-setup @@ -27,6 +27,13 @@ Setup exim4 / postfix / dovecot The minimal assumption we have is that /etc/mailpass exists + +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 +setup. + -h|--help Print help and exit. EOF exit $1 diff --git a/mount-latest-subvol b/mount-latest-subvol index be239ed..d7be613 100644 --- a/mount-latest-subvol +++ b/mount-latest-subvol @@ -117,10 +117,14 @@ EOF shopt -s nullglob +# ssh and probably some other things care about parent directory +# ownership, and ssh doesn\'t allow any group writable parent +# directories, so we are forced to use a directory structure similar +# to home directories f=(/mnt/root/btrbk/q.*) if [[ -e $f ]]; then fstab <