From: Ian Kelling <iank@fsf.org>
Date: Thu, 4 Apr 2019 16:28:31 +0000 (-0400)
Subject: various bug fixes
X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=90bd397922e7240c41377e7404f79f190bfbc9d8;p=distro-setup

various bug fixes
---

diff --git a/.bashrc b/.bashrc
index d0c4b02..097dd98 100644
--- a/.bashrc
+++ b/.bashrc
@@ -51,7 +51,7 @@ if [[ $SSH_CONNECTION ]] \
        && [[ ! $SSH_TTY ]] \
        && [[ $- != *i* ]] \
        && [[ ! $BASH_LOGIN_SHELL == true ]]; then
-    return
+    return 0
 else
     if [[ -r /etc/profile ]]; then
         source /etc/profile
@@ -62,3 +62,5 @@ else
         source $_x
     fi
 fi
+# ensure no bad programs appending to this file will have an affect
+return 0
diff --git a/.profile b/.profile
index 6596cb5..96ca117 100644
--- a/.profile
+++ b/.profile
@@ -1,2 +1,7 @@
 # see .bashrc_profile for commentary
 echo this is ~/.profile, either my .bashrc_profile is unavailable or this is posix mode or not bash
+
+# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
+export PATH="$PATH:$HOME/.rvm/bin"
+
+[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
diff --git a/brc b/brc
index 08f4e79..9851fe4 100644
--- a/brc
+++ b/brc
@@ -2205,27 +2205,7 @@ fi
 #  eval "$(pyenv virtualenv-init -)"
 #fi
 
-# id prefer to have system-wide, plus user ruby, due to bug in it
-# https://github.com/rubygems/rubygems/pull/1002
-# further problems: installing multi-user ruby and user ruby,
-# you dont get multi-user ruby when you sudo to root, unless its sudo -i.
-# There a third hybrid form, which passenger error suggested I use,
-# but it didnt actually work.
-
-# in cased I never need this
-# rvm for non-interactive shell: modified from https://rvm.io/rvm/basics
-#if [[ $(type -t rvm) == file && ! $(type -t ruby) ]]; then
-#    source $(rvm 1.9.3 do rvm env --path)
-#fi
-
-# based on warning from rvmsudo
-export rvmsudo_secure_path=1
 
-if [[ -s "/usr/local/rvm/scripts/rvm" ]]; then
-  source "/usr/local/rvm/scripts/rvm"
-elif [[ -s $HOME/.rvm/scripts/rvm ]]; then
-  source $HOME/.rvm/scripts/rvm
-fi
 
 export GOPATH=$HOME/go
 path_add $GOPATH/bin
@@ -2234,6 +2214,10 @@ export ARDUINO_PATH=/a/opt/Arduino/build/linux/work
 
 path_add --end ~/.npm-global
 
+# taken from default changes to bashrc and bash_profile
+path_add --end $HOME/.rvm/bin
+[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
+
 export BASEFILE_DIR=/a/bin/fai-basefiles
 
 # didnt get drush working, if I did, this seems like the
diff --git a/btrbk-run b/btrbk-run
old mode 100755
new mode 100644
index 6024229..b753b5d
--- a/btrbk-run
+++ b/btrbk-run
@@ -24,7 +24,11 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 usage() {
   cat <<'EOF'
 btrbk-run [OPTIONS]
-usually -t TARGET_HOST
+usually -t TARGET_HOST or -s SOURCE_HOST
+
+Note, at source location, intentionally not executable, run and read
+install-my-scripts.
+
 EOF
   echo "top of script file:"
   sed -n '1,/^[# ]*end command line/{p;b};q' "$0"
diff --git a/check-subvol-stale b/check-subvol-stale
index 9959421..6a63124 100644
--- a/check-subvol-stale
+++ b/check-subvol-stale
@@ -25,7 +25,7 @@ usage() {
   cat <<EOF
 usage: $0 SUBVOL_MOUNTPOINT...
 
-In git, this is not not executable because it's meant to be installed
+In git this is not not executable because it's meant to be installed
 using ./install-my-scripts
 
 If latest subvols \$@ are not mounted, exit 1, print message, and print
diff --git a/distro-begin b/distro-begin
index 35c904a..182a9d9 100755
--- a/distro-begin
+++ b/distro-begin
@@ -33,15 +33,8 @@ interactive=true  # set this to false to force set -x
 [[ $- == *i* ]] || interactive=false
 if ! $interactive; then
     set -x
-    set -e -o pipefail
 fi
-set -E
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
-for x in /a/bin/errhandle/*-function; do
-    source $x
-done
-set +e
-$interactive || errcatch
+source /a/bin/errhandle/err
 
 ### setup logging
 exec &> >(sudo tee -a /var/log/distro-begin)
@@ -77,7 +70,7 @@ source $script_dir/pkgs
 set +x
 source /a/bin/distro-functions/src/identify-distros
 $interactive || set -x
-for f in iank-dev htpc kd x2 frodo tp li lj demohost kw fz; do
+for f in iank-dev htpc kd x2 x3 frodo tp li lj demohost kw fz; do
     eval "$f() { [[ $HOSTNAME == $f ]]; }"
 done
 has_p() { ! linode; } # when tp is tracis, then not tp either
@@ -207,10 +200,10 @@ conflink
 
 ###### bash environment setup
 set +x
-errallow
+err-allow
 source /etc/profile.d/environment.sh
 source ~/.bashrc
-$interactive || errcatch
+err-catch
 $interactive || set -x
 
 
@@ -319,6 +312,7 @@ if has_p; then
 fi
 s lnf /q/root/.editor-backups /q/root/.undo-tree-history \
   /a/opt /a/c/.emacs.d $HOME/mw_vars /k/backup /root
+pi rsync # needed for rootsshsync
 rootsshsync
 s lnf /a/c/.vim /a/c/.vimrc /a/c/.gvimrc /root
 if has_p; then
@@ -566,7 +560,7 @@ if has_x; then
 fi
 
 ##### install laptop hardware packages
-if tp || x2; then
+if tp || x2 || x3; then
     case $distro in
         debian)
             pi task-laptop
diff --git a/distro-end b/distro-end
index 43ca158..d72adea 100755
--- a/distro-end
+++ b/distro-end
@@ -617,7 +617,7 @@ esac
 # s cp -r --parents /etc/openvpn/easy-rsa/keys /p/c/filesystem
 # s chown -R 1000:1000 /p/c/filesystem/etc/openvpn/easy-rsa/keys
 # # kw = kgpe work machine.
-# for host in x2 kw; do
+# for host in x2 x3 kw; do
 # vpn-mk-client-cert -b $host -n home b8.nz 1196
 # dir=/p/c/machine_specific/$host/filesystem/etc/openvpn/client
 # mkdir -p $dir
@@ -911,25 +911,21 @@ Pin-Priority: -100
 Package: *
 Pin: release a=xenial-updates
 Pin-Priority: -100
+
+Package: *
+Pin: release a=xenial-security
+Pin-Priority: -100
 EOF
     s dd of=/etc/apt/sources.list.d/xenial.list 2>/dev/null <<EOF
 deb http://us.archive.ubuntu.com/ubuntu/ xenial main
 deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main
+deb http://us.archive.ubuntu.com/ubuntu/ xenial-security main
 EOF
     curl http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg | s apt-key add -
     p update
 
     t=$(mktemp -d)
     cd $t
-    s dd of=/etc/apt/preferences.d/flidas-xenial <<EOF
-Package: debootstrap
-Pin: release a=xenial
-Pin-Priority: 1001
-
-Package: debootstrap
-Pin: release a=xenial-updates
-Pin-Priority: 1001
-EOF
     aptitude download debootstrap
     ex *
     ex data.tar.gz
@@ -1386,7 +1382,7 @@ fi
 # EOF
 #         s systemctl daemon-reload
 #         case $HOSTNAME in
-#             x2|tp)
+#             x2|x3|tp)
 #                 ser enable synergyc@iank
 #                 ser start synergyc@iank ||: # X might not be running yet
 #                 ;;
diff --git a/install-my-scripts b/install-my-scripts
index e2356ca..2f9e224 100755
--- a/install-my-scripts
+++ b/install-my-scripts
@@ -31,4 +31,4 @@ x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*}
 e() { echo "$*"; "$@"; }
 
 # scripts that would interfere with unmounting /a, put them elsewhere
-e install mount-latest-subvol check-subvol-stale /usr/local/bin
+e install btrbk-run mount-latest-subvol check-subvol-stale /usr/local/bin
diff --git a/mount-latest-subvol b/mount-latest-subvol
index d36685f..96210c4 100644
--- a/mount-latest-subvol
+++ b/mount-latest-subvol
@@ -14,6 +14,9 @@
 # limitations under the License.
 
 # usage: mount-latest-subvol
+#
+# Note, at source location, intentionally not executable, run and read
+# install-my-scripts.
 
 cd /
 [[ $EUID == 0 ]] || exec sudo -E "$BASH_SOURCE" "$@"
@@ -86,7 +89,7 @@ pid-check() {
   for p in ${pids}; do
     for m in ${my_pids[@]}; do
       if (( p == m )); then
-        echo "$0: error: pids to kill includes our pid or a parent" >&2
+        echo "$0: error: pids to kill includes our pid or a parent. ps output:" >&2
         ps -f -p $p
         exit 1
       fi
diff --git a/subdir_files/.gnupg/gpg.conf b/subdir_files/.gnupg/gpg.conf
index 9641d86..d5b5c41 100644
--- a/subdir_files/.gnupg/gpg.conf
+++ b/subdir_files/.gnupg/gpg.conf
@@ -34,11 +34,12 @@ default-key B125F60B7B287FF6A2B7DF8F170AF0E2954295DF
 # install -o iank -g iank -d -m700 /home/iank/gpg-agent-socket
 # because something keeps deleting that directory
 
-# default keyserver
+# default keyserver. i switch around randomly to find one that is up.
 #
 #keyserver hkp://pgp.mit.edu
-# this one seems more reliable, but it's down now
-keyserver hkp://pool.sks-keyservers.net
+#keyserver hkp://pool.sks-keyservers.net
+#keyserver hkp://keyserver.pgp.com
+keyserver hkp://ipv4.pool.sks-keyservers.net
 
 # more secure, but had problems with my gpg version
 #keyserver hkps://hkps.pool.sks-keyservers.net