summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 165008e)
raw | patch | inline | side by side (parent: 165008e)
author | Ian Kelling <ian@iankelling.org> | |
Tue, 12 Nov 2019 17:55:15 +0000 (12:55 -0500) | ||
committer | Ian Kelling <ian@iankelling.org> | |
Tue, 12 Nov 2019 17:55:15 +0000 (12:55 -0500) |
14 files changed:
brc | patch | blob | history | |
brc2 | patch | blob | history | |
btrbk-run | patch | blob | history | |
conflink | patch | blob | history | |
desktop-20-autostart.sh | patch | blob | history | |
distro-begin | patch | blob | history | |
distro-end | patch | blob | history | |
distro-pkgs | patch | blob | history | |
filesystem/etc/systemd/system/fsf-vpn-dns-cleanup.service | patch | blob | history | |
mail-route | patch | blob | history | |
mail-setup | patch | blob | history | |
pkgs | patch | blob | history | |
sl/.iank/package-manager-abstractions | [new symlink] | patch | blob |
switch-mail-host | patch | blob | history |
index b5d45969c67b9364d6dfc783d187be1873d27707..51a04dcac0d59c3a29bd081522ee11a51dc738da 100644 (file)
--- a/brc
+++ b/brc
ccat () { # config cat. see a config without extra lines.
- grep '^\s*[^;[:space:]#]' "$@"
+ grep '^\s*[^;[:space:]#]' "$@" || [[ $? == 1 ]]
}
k() { # history search
- grep -P --binary-files=text "$@" ${HISTFILE:-~/.bash_history} | tail -n 80;
+ grep -P --binary-files=text "$@" ${HISTFILE:-~/.bash_history} | tail -n 80 || [[ $? == 1 ]];
}
ks() { # history search
- grep -P --binary-files=text "$@" ${HISTFILE:-~/.bash_history} | uniq;
+ grep -P --binary-files=text "$@" ${HISTFILE:-~/.bash_history} | uniq || [[ $? == 1 ]];
}
c $(mktemp -d)
pkg=$1
# shellcheck disable=SC2012
- cached=$(ls -t /var/cache/apt/archives/$pkg* | tail -n1 2>/dev/null)
+ cached=$(ls -t /var/cache/apt/archives/$pkg* | tail -n1 2>/dev/null) ||:
if [[ $cached ]]; then
cp $cached .
else
index 891e0953b668e7e69d847f54e5f4ad24f768fff5..56f4db6c860d4ff83bb91a254ab3a0eb683e33cf 100644 (file)
--- a/brc2
+++ b/brc2
}
_jrun() { # journal run. run args, log to journal, tail and grep the journal.
+ # Redirect all commands which might have stderr to stdout because of
+ # wrapping.
local pid pattern jr_pid sedscript cmd_name ended
ret=0
case $1 in
-p)
- pattern="$2\|"
+ pattern="$2|"
shift 2
;;
esac
cmd_name=${1##*/}
systemd-cat -t "$cmd_name" "$@" 2>&1 &
pid=$!
- sedscript="/$pattern$cmd_name/p;/^.{16}[^ ]+ $cmd_name\[$pid]: ([^ ]+ +)?exiting with status [0-9]+\$/q"
+ sedscript="/$pattern$cmd_name/p;/^.{16}[^ ]+ $cmd_name\[$pid]: $cmd_name: exiting with status [0-9]+\$/q"
journalctl -S "4 seconds ago" -f |& sed -nr "$sedscript" 2>&1 &
jr_pid=$!
wait $pid 2>&1 || ret=$?
done < "$file"
}
+failfunc() { asdf a b c; }
+failfunc2() { failfunc d e f; }
# one that comes with distros is too old for newer devices
fastboot() {
#hr; echo dnsmasq is $(systemctl is-active dnsmasq)
f=/var/run/dnsmasq/resolv.conf
hr; echo $f:; ccat $f
- hr; m grr '^ *servers-file *=' /etc/dnsmasq.conf /etc/dnsmasq.d
+ hr; m grr '^ *(servers-file|server) *=|^ *no-resolv *$' /etc/dnsmasq.conf /etc/dnsmasq.d
f=/etc/dnsmasq-servers.conf
hr; echo $f:; ccat $f
}
diff --git a/btrbk-run b/btrbk-run
index 60f065d62e568732cff437d501a1f108d2792f2f..3a2d2a493495fb2fc422f02b9f5f80b52c632b39 100644 (file)
--- a/btrbk-run
+++ b/btrbk-run
m() { if $verbose; then printf "$pre%s\n" "$*"; fi; "$@"; }
e() { printf "$pre%s\n" "$*"; }
die() { printf "$pre%s\n" "$*" >&2; echo "exiting with status 1" >&2; exit 1; }
-mexit() { echo "exiting with status $1"; exit $1; }
+mexit() { echo "$pre: exiting with status $1"; exit $1; }
# latest $MAIL_HOST
if [[ -e /b/bash_unpublished/source-state ]]; then
rsync_mountpoint=/q
+ret=0
# default options
conf_only=false
dry_run=false # mostly for testing
m /a/exe/mount-latest-remote ${targets[@]}
fi
-e btrbk-run COMPLETED with exit status $ret
mexit $ret
# todo: move variable data we don't care about backing up
diff --git a/conflink b/conflink
index 61291f2b42b643dfc2f68008032e892de501da64..8deae093a7bbee829a72ab1cc590ed8a91390372 100755 (executable)
--- a/conflink
+++ b/conflink
#!/bin/bash
source /a/bin/errhandle/err
-errcatch-cleanup() {
+err-cleanup() {
echo 1 >~/.local/conflink
}
# A = preserve acls
# X = preserve extended attributes
# i = itemize
- done < <(s rsync -n -aiSAX --chown=root:root --chmod=g-s \
+ done < <(s rsync -aiSAX --chown=root:root --chmod=g-s \
--exclude=/etc/dovecot/users \
--exclude='/etc/exim4/passwd*' \
--exclude='/etc/exim4/*.pem' \
index ed83642aa02c9a9173695cd846da4e7e7155fb6e..69f455f47d21da37bc5d90d206d4f20427a7c58c 100755 (executable)
--- a/desktop-20-autostart.sh
+++ b/desktop-20-autostart.sh
# limitations under the License.
# first 2 alternatives showed under ubuntu 14.04, second 2 under arch at 11/2015
-if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
if [[ $1 ]]; then
- right_monitor_rotation=left
+ right_monitor_rotation=left
else
- right_monitor_rotation=normal
+ right_monitor_rotation=normal
fi
-xout="$(xrandr)"
+if ! xout="$(xrandr)"; then
+ # under wayland
+ exit 0
+fi
xe() { echo "$xout"; }
x=$(xe | grep -Ec '^(DisplayPort-[0123]|DVI-0|DP-[1234]|DVI-I-1) connected')
if (( x > 2 )); then
- left=$(xe | sed -rn 's/^(DVI[^ ]+) connected .*/\1/p')
- dps=( $(xe | sed -rn 's/^(DP-[01234]|DisplayPort-[01234]) connected .*/\1/p') )
+ left=$(xe | sed -rn 's/^(DVI[^ ]+) connected .*/\1/p')
+ dps=( $(xe | sed -rn 's/^(DP-[01234]|DisplayPort-[01234]) connected .*/\1/p') )
- middle=${dps[1]}
- right=${dps[0]}
- # on older distros, i needed to swap middle and right.
+ middle=${dps[1]}
+ right=${dps[0]}
+ # on older distros, i needed to swap middle and right.
- xrandr --output $left --mode 2560x1600 --pos 0x0 --rotate left \
- --output $middle --mode 2560x1600 --pos 1600x0 --rotate left \
- --output $right --mode 2560x1600 --pos 3200x0 --rotate $right_monitor_rotation
+ xrandr --output $left --mode 2560x1600 --pos 0x0 --rotate left \
+ --output $middle --mode 2560x1600 --pos 1600x0 --rotate left \
+ --output $right --mode 2560x1600 --pos 3200x0 --rotate $right_monitor_rotation
elif (( x == 2 )); then
- # 3rd monitor not working atm, so doing this.
- left=$(xe | sed -rn 's/^(DVI[^ ]+) connected .*/\1/p')
- middle=$(xe | sed -rn 's/^(DP-[01234]|DisplayPort-[01234]) connected .*/\1/p')
- xrandr --output $left --mode 2560x1600 --pos 0x0 --rotate left \
- --output $middle --mode 2560x1600 --pos 1600x0 --rotate left
+ # 3rd monitor not working atm, so doing this.
+ left=$(xe | sed -rn 's/^(DVI[^ ]+) connected .*/\1/p')
+ middle=$(xe | sed -rn 's/^(DP-[01234]|DisplayPort-[01234]) connected .*/\1/p')
+ xrandr --output $left --mode 2560x1600 --pos 0x0 --rotate left \
+ --output $middle --mode 2560x1600 --pos 1600x0 --rotate left
fi
/a/bin/distro-setup/input-setup m
if isarch; then
- pulseaudio --start
+ pulseaudio --start
fi
#indicator-kdeconnect
diff --git a/distro-begin b/distro-begin
index 22fff60409d135d21ae76167ae28e2de5a9df3b5..72d4d44f613e6ca7ef521dac93344526fc6a753f 100755 (executable)
--- a/distro-begin
+++ b/distro-begin
fi
source /a/bin/errhandle/err
-errcatch-cleanup() {
+err-cleanup() {
echo 1 >~/.local/distro-begin
}
source /a/bin/distro-functions/src/package-manager-abstractions
### setup logging
-exec &> >(sudo tee -a /var/log/distro-begin)
echo "$0: $(date): starting now)"
######## fix evbug bug ######
-case $distro in
- trisquel|ubuntu)
- # noticed in flidas.
+case $(debian-codename-compat) in
+ xenial)
+ # noticed in flidas. dunno if it affects any others
#https://bugs.launchpad.net/ubuntu/+source/module-init-tools/+bug/240553
#https://wiki.debian.org/KernelModuleBlacklisting
#common advice when searching is to use /etc/modprobe.d/blacklist.conf,
lnf -T /p/News ~/News
fi
sudo /a/exe/lnf /q/root/.editor-backups /q/root/.undo-tree-history \
- /a/opt /a/c/.emacs.d $HOME/mw_vars /k/backup /root
+ /a/opt /a/c/.emacs.d $HOME/mw_vars /k/backup /root
/a/bin/ds/install-my-scripts # needed for rootsshsync cronjob
sudo /a/exe/lnf /a/c/.vim /a/c/.vimrc /a/c/.gvimrc /root
esac
##### setup X autostart
- if isarch; then
- # https://wiki.archlinux.org/index.php/Xinitrc
- for homedir in /home/*; do
- cp /etc/X11/xinit/xinitrc $homedir/.xinitrc
- # shellcheck disable=SC2016
- $sed -ri '/^ *twm\b/,$d' $homedir/.xinitrc
- tee -a $homedir/.xinitrc <<'EOF'
-/a/bin/desktop-20-autostart.sh
-xsetroot -cursor_name left_ptr
-exec xmonad
-EOF
- done
- else
- # todo, figure this out for arch if we ever try out gnome.
- # install for multiple display managers in case we use one
- dir=/etc/gdm3
- sudo mkdir -p $dir/PostLogin
- sudo cp /a/bin/distro-setup/desktop-20-autostart.sh $dir/PostLogin/Default
- sudo mkdir -p /etc/lightdm/lightdm.conf.d
- sudo dd of=/etc/lightdm/lightdm.conf.d/12-iank.conf <<'EOF'
+ # todo, figure this out for arch if we ever try out gnome.
+ # install for multiple display managers in case we use one
+ dir=/etc/gdm3
+ sudo mkdir -p $dir/PostLogin
+ sudo cp /a/bin/distro-setup/desktop-20-autostart.sh $dir/PostLogin/Default
+ sudo mkdir -p /etc/lightdm/lightdm.conf.d
+ sudo 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
### install and configure wayland
echo 0 >~/.local/distro-begin
echo "$0: $(date): ending now"
+echo "exiting with status 0"
exit 0
diff --git a/distro-end b/distro-end
index d63d315d3da01c6a275bd2d68dda08ee0fed1e8b..18edaa56b8db4e3485e37f9d327acbdf62c40343 100755 (executable)
--- a/distro-end
+++ b/distro-end
exit 1
fi
-errcatch-cleanup() {
+err-cleanup() {
echo 1 >~/.local/distro-end
}
# shellcheck source=./pkgs
source $src/pkgs
-exec &> >(sudo tee -a /var/log/distro-end)
-echo "$0: $(date): starting now)"
+echo "$0: $(date) starting now)"
# see example of usage to understand.
end_msg() {
local y
echo 0 >~/.local/distro-end
if $pending_reboot; then
echo "$0: pending reboot and then finished. doing it now."
+ echo "exiting with status 0"
sudo reboot now
else
echo "$0: $(date): ending now)"
+ echo "exiting with status 0"
fi
exit 0
}
### begin certbot install ###
-if [[ $distro == debian ]]; then
+if [[ $distro == debian || $codename_compat == bionic ]]; 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
+ pi certbot python3-certbot-apache
elif [[ $codename_compat == xenial ]]; then
# not packaged in xenial or flidas
pi software-properties-common
# mate doesnt have wayland support yet
pi task-gnome-desktop
;;
+ bionic)
+ pi gnome-core
+ ;;
esac
+if [[ $codename_compat == flidas ]]; then
+ # doesnt exist in newer
+ pi gnupg-doc
+fi
+if [[ $codename == flidas ]]; then
+ pi abrowser
+else
+ pi firefox
+ sudo ln -sf /usr/bin/firefox /usr/local/bin/abrowser
+fi
# TODO: some of the X programs can be removed from pall when using wayland
pi ${pall[@]} $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}') $(apt-cache depends gcc|grep -i suggests:| awk '{print $2}') $($src/distro-pkgs)
-sgo fsf-vpn-dns-cleanup
-
-
# website is dead june 14 2019. back in october, but meh
sudo rm -fv /etc/apt/sources.list.d/iridium-browser.list
# case $distro in
case $codename in
flidas)
-
- ;;
+ :
+ ;;
esac
# in arch, I had to pick out the 6L driver.
-# allow user to run vms, from debian handbook
-for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
# bridge networking as user fails. google lead here, but it doesn\'t work:
# oh well, I give up.
# http://wiki.qemu.org/Features-Done/HelperNetworking
m /a/bin/buildscripts/misc
pi-nostart virtinst virt-manager
-
+# allow user to run vms, from debian handbook
+for x in iank user2; do s usermod -a -G libvirt,kvm $x; done
pi --no-install-recommends kdeconnect
########### misc stuff
+pi-nostart network-manager
# make networkmanager use resolvconf instead of its own dnsmasq which
# conflicts with the normal dnsmasq package.
f=/etc/NetworkManager/NetworkManager.conf
# displays l and I as the same char, grrrrr.
sudo fc-cache
+pi desktop-file-utils
m /a/bin/distro-setup/mymimes
diff --git a/distro-pkgs b/distro-pkgs
index b69af1a68933b2a0573702924cb428b5e5615bb4..ab6fa6495689aecb723f9ca561d9ee368b049e46 100755 (executable)
--- a/distro-pkgs
+++ b/distro-pkgs
*) : ;; # 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 ;;
diff --git a/filesystem/etc/systemd/system/fsf-vpn-dns-cleanup.service b/filesystem/etc/systemd/system/fsf-vpn-dns-cleanup.service
index 3e50599bc9d5f2a8e202d503e633be1ffc0425c6..2f6d9bb8fca34f0057ad1899d0a27325d0595428 100644 (file)
# If we reboot, or the vpn dies in an unusual way, it leaves dnsmasq config hanging around.
-# This cleans that up.
[Unit]
Description=fsf-vpn-dns-cleanup
After=multi-user.target
-Conflicts=openvpn-client@fsf80.service openvpn-client@fsf802.service openvpn-client@fsf803.service openvpn-client@fsf443.service openvpn-client@fsf4432.service openvpn-client@fsf4433.service
+Conflicts=openvpn-client@fsf80.service openvpn-client@fsf802.service openvpn-client@fsf803.service openvpn-client@fsf443.service openvpn-client@fsf4432.service openvpn-client@fsf4433.service openvpn@fsf80.service openvpn@fsf802.service openvpn@fsf803.service openvpn@fsf443.service openvpn@fsf4432.service openvpn@fsf4433.service
[Service]
Type=oneshot
diff --git a/mail-route b/mail-route
index 2dc237da63c3b563716d1c9616e5d07c1ebb4a63..a1c1b478a22d1ff16466bbb3a43e06c2b8088029 100755 (executable)
--- a/mail-route
+++ b/mail-route
fi
fi
e() { echo "$0: $*"; "$@"; }
- errcatch-cleanup() { stop; }
+ err-cleanup() { stop; }
modify
# we leave it as is even when stopping, because we would like it to be default, but the only way
# to change the default is for every device, and I want to avoid that, even though I wouldn't mind, others users of this script might.
diff --git a/mail-setup b/mail-setup
index 3dd3e970cde04fb3a77618c64b6e1e748c9f88f1..6f96982c559c23c9542856f1efda1a145321966e 100755 (executable)
--- a/mail-setup
+++ b/mail-setup
## * Install packages
# light version of exim does not have sasl auth support.
-pi exim4-daemon-heavy spamassassin spf-tools-perl openvpn dnsmasq
+pi exim4-daemon-heavy spamassassin spf-tools-perl dnsmasq openvpn
+# our nostart pi fails to avoid enabling
+sudo systemctl disable openvpn
# trisquel 8 = openvpn, debian stretch = openvpn-client
vpn_ser=openvpn-client
fi
if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
local_mx=mail.iankelling.org
+ mkdir -p /etc/letsencrypt/live/$local_mx
+ chmod 700 /etc/letsencrypt/live
rsync_common="rsync -ogtL --chown=root:Debian-exim --chmod=640 root@li.iankelling.org:/etc/letsencrypt/live/$local_mx/"
${rsync_common}fullchain.pem /etc/exim4/exim.crt
ret=$?
# * common exim4 config
source /a/bin/bash_unpublished/source-state
+if [[ ! $MAIL_HOST ]]; then
+ err "\$MAIL_HOST not set"
+fi
+
m sudo gpasswd -a iank adm #needed for reading logs
m ln -sf -T /m/md/bounces $d
done
+# Note, even the server needs permissions of this file right
+# if it exists, so do this up here.
+f=/p/c/filesystem/etc/exim4/passwd.client
+if [[ ! -e $f ]]; then
+ f=/p/c/machine_specific/$HOSTNAME/filesystem/etc/exim4/passwd.client
+fi
+m sudo rsync -ahhi --chown=root:Debian-exim --chmod=0640 $f /etc/exim4/
# by default, only 10 days of logs are kept. increase that.
m sed -ri 's/^(\s*rotate\s).*/\11000/' /etc/logrotate.d/exim4-base
hostname -f >/etc/mailname
- f=/p/c/filesystem/etc/exim4/passwd.client
- if [[ ! -e $f ]]; then
- f=/p/c/machine_specific/$HOSTNAME/filesystem/etc/exim4/passwd.client
- fi
- m sudo rsync -ahhi --chown=root:Debian-exim --chmod=0640 $f /etc/exim4/
;;&
## we use this host to monitor MAIL_HOST
index 59e35eade60d0b50c290e5772021264bd826321c..55126fd1357030b54080afb3e06856c14ad0622d 100644 (file)
--- a/pkgs
+++ b/pkgs
goaccess
gnat-5
gnome-screenshot
- gnupg-doc
grepmail
guvcview
hunspell
diff --git a/sl/.iank/package-manager-abstractions b/sl/.iank/package-manager-abstractions
--- /dev/null
@@ -0,0 +1 @@
+/a/bin/distro-functions/src/package-manager-abstractions
\ No newline at end of file
diff --git a/switch-mail-host b/switch-mail-host
index 14a11f866ab3b03ea0d51eedf833e7782a38d848..eafe1044c0816c19aa7522b94445d6a3de7cec78 100644 (file)
--- a/switch-mail-host
+++ b/switch-mail-host
restore_new_btrbk=false
restore_old_btrbk=false
-errcatch-cleanup() {
+err-cleanup() {
if $restore_new_btrbk; then
e WARNING: due to failure, btrbk.timer may need manual restoration:
e $new_shell sudo systemctl start btrbk.timer
pre="${0##*/}:"
m() { printf "$pre %s\n" "$*"; "$@"; }
e() { printf "$pre %s\n" "$*"; }
-err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $pre: $*" >&2; }
-mexit() { echo "exiting with status $1"; exit $1; }
+err() { echo "$pre: ERROR: $*" >&2; }
+mexit() { echo "$pre: exiting with status $1"; exit $1; }
##### begin command line parsing ########
(( $# == 2 )) || usage 1
+if [[ ! $HOSTNAME ]]; then
+ err '$HOSTNAME is unset'
+ mexit 1
+fi
case $1 in
push)
+ old_host=$HOSTNAME
new_host=$2
bbk_args="-s $old_host"
new_shell="ssh $new_host"
- old_host=$HOSTNAME
+ new_hostname=$($new_shell hostname)
;;
pull)
old_host=$2
+ new_host=$HOSTNAME
+ new_hostname=$HOSTNAME
bbk_args="-t $new_host"
bbk_args="-s $old_host"
- new_host=$HOSTNAME
old_shell="ssh $old_host"
+ # test ssh connection
+ $old_shell :
;;
*)
err invalid first argument
;;
esac
-
source /a/bin/bash_unpublished/source-state
if [[ $old_host != "$MAIL_HOST" ]]; then
mexit 1
fi
-e $new_shell hostname
-new_hostname=$($new_shell hostname)
########### end initial processing, begin actually modifying things ##########