mostly reorganizing and cleanup
authorIan Kelling <iank@fsf.org>
Sun, 28 Jan 2018 17:58:52 +0000 (12:58 -0500)
committerIan Kelling <iank@fsf.org>
Sun, 28 Jan 2018 17:58:52 +0000 (12:58 -0500)
.inputrc
brc
desktop-20-autostart.sh
desktop-apps
distro-begin
distro-end
filesystem/etc/X11/Xsession.d/98iank
filesystem/etc/profile.d/environment.sh
mail-setup
pkgs [new file with mode: 0644]
switch-mail-host

index 76d3577a0daf28413c87ebc4c1d43f8142e41413..51d74a799e631e7c811886a514a307ce1cf3e134 100644 (file)
--- a/.inputrc
+++ b/.inputrc
@@ -46,10 +46,13 @@ set mark-symlinked-directories on
 # C-x would be hard to rebind because emacs.
 
 "\C-q": exchange-point-and-mark
+# default not bound
 "\C-w": kill-region
-"\C-e": yank-last-arg
+# default M-S-3
 "\C-a": insert-comment
-"\C-s": yank-nth-arg
+
+# default is C-M-y
+"\e,": yank-nth-arg
 
 "\C-f": menu-complete
 "\C-b": menu-complete-backward
diff --git a/brc b/brc
index 53f8c5b0074cc3cf62650238027c4684fea347de..fbc1acb2f653cc50467d6aeb9f6ff036cfc32c7a 100644 (file)
--- a/brc
+++ b/brc
@@ -558,7 +558,7 @@ fa() {
 }
 
 faf() { # find all files
-    find -L $1 -type f -not \( -name .svn -prune -o -name .git -prune \
+    find -L $1 -not \( -name .svn -prune -o -name .git -prune \
          -o -name .hg -prune -o -name .editor-backups -prune \
          -o -name .undo-tree-history -prune \) 2>/dev/null
 }
index 3d5b7191f4fba539d565b0aceec1ecfd2ccaa125..df8dab8223779968545d3e41ab9076d70653abf6 100755 (executable)
@@ -45,9 +45,16 @@ elif (( x == 2 )); then
            --output $middle --mode 2560x1600 --pos 1600x0 --rotate left
 
 fi
-/a/bin/distro-setup/input-setup
+/a/bin/distro-setup/input-setup m
 if isarch; then
     pulseaudio --start
 fi
+
+/a/exe/lnf -T /p/arbtt-capture.log ~/.arbtt/capture.log
+# docs say a sample rate less than 20 is probably not worth the data cost,
+# but it seems pretty small to me
+arbtt-capture --sample-rate=10 &
+
+
 #indicator-kdeconnect
 date "+%A, %B %d, %r, %S seconds" > /tmp/desktop-20-autostart-log
index a0ed3c7ec7140733391730babb0e019717d3dd82..bcbda09deddad245b80306136af66f4f7add9c18 100755 (executable)
@@ -2,6 +2,7 @@
 
 if ! pgrep -u $EUID emacs; then
     emacs --daemon &
+    emacs -f znc-all &
 fi
 pidgin &
 linphone &
index 9a7a9adae33d41b3298d98e78971d2cba1556a0c..08ea004c609904244631e2a0c4712a432b7d89b1 100755 (executable)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
-
-
-# for bootstrapping a new machine
-
-# in case we need it,
-# to make ssh interactive shell run better, we run this first.
-sudo bash -c 'source /a/c/.bashrc && source /a/exe/ssh-emacs-setup'
-
-
+# for setting up a new machine
 # usage: $0 [-r] HOSTNAME
 
 # tips:
 # run any sudo command first so your pass is cached
 # set the scrollback to unlimited in case something goes wrong
 
-if [[ $EUID == 0 ]]; then
-    if getent passwd iank || getent passwd ian ; then
-        echo "$0: error: running as root. unprivileged user exists. use it."
-        exit 1
-    else
-        echo "$0: warning: running as root. I will setup users then exit"
-    fi
-fi
 
+####### begin setup environment #######
+
+
+### make ssh interactive shell run better. for when running line interactively line by line
+sudo bash -c 'source /a/c/.bashrc && source /a/exe/ssh-emacs-setup'
+
+
+##### setup error handling
 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
 
+### setup logging
 exec &> >(sudo tee -a /var/log/distro-begin)
 echo "$0: $(date): starting now)"
 
-# headless=false # unused atm
+
+### sanity checking
+if [[ $EUID == 0 ]]; then
+    if getent passwd iank || getent passwd ian ; then
+        echo "$0: error: running as root. unprivileged user exists. use it."
+        exit 1
+    else
+        echo "$0: warning: running as root. I will setup users then exit"
+    fi
+fi
+
+
+### arg parsing
 recompile=false
 # for copying to a new data fs
 bootstrapfs=false # old flag, needs new look before using.
@@ -60,11 +68,17 @@ while [[ $1 == -* ]]; do
         -r) recompile=true; shift ;;
     esac
 done
-
 if [[ $1 ]]; then
     export HOSTNAME=$1
 fi
 
+
+##### variables/env setup
+script_dir="$(readlink -f "$BASH_SOURCE")"
+source $script_dir/pkgs
+set +x
+source /a/bin/distro-functions/src/identify-distros
+$interactive || set -x
 for f in iank-dev htpc treetowl x2 frodo tp li lj demohost kw fz; do
     eval "$f() { [[ $HOSTNAME == $f ]]; }"
 done
@@ -74,16 +88,16 @@ linode() { lj || li; }
 has_btrfs() { ! linode; }
 home_network() { ! linode; }
 encrypted() { has_p; }
-
 shopt -s extglob
 export GLOBIGNORE=*/.:*/..
-umask 0002
+umask 022
+PATH="/a/exe:$PATH"
+sed="sed --follow-symlinks"
+
+####### end setup environment #######
 
 
-####### end command line parsing
 
-PATH="/a/exe:$PATH"
-sed="sed --follow-symlinks"
 
 ##### begin setup encryption scripts ######
 if encrypted; then
@@ -133,27 +147,16 @@ fi
 ##### end setup encryption scripts ######
 
 
-install-myqueue
+# disabled until its fixed up
+# install-myqueue
 
-# this script has been designed to be idempotent
 # todo, it would be nice to cut down on some of the output
 
-
-for x in /a/bin/errhandle/*-function; do
-    source $x
-done
-
-
-set +e
-$interactive || errcatch
-set +x
-source /a/bin/distro-functions/src/identify-distros
-$interactive || set -x
-
+##### fedora prereq/fundamental settings
 if isfedora; then
     # comment out line disallowing calling sudo in scripts
     sudo $sed -i 's/^Defaults *requiretty/#\0 # ian commented/' /etc/sudoers
-    # turn on magic sysrq commands for this boot cycle
+    # turn on magic sysrq commands
     echo 1 > sudo dd of=/proc/sys/kernel/sysrq
     echo "kernel.sysrq = 1" > /etc/sysctl.d/90-sysrq.conf
     # selinux is not user friendly. Like, you enable samba, but you haven't run the magic selinux commands so it doesn't work
@@ -163,6 +166,7 @@ if isfedora; then
 fi
 
 
+#### rerun my fai-time scripts
 # already ran for pxe installs, but used for vps & updates
 distro=$(distro-name)
 case $distro in
@@ -175,25 +179,27 @@ case $distro in
         ;;
 esac
 
+###### setup hostname
 sudo $sed -i '/^127\.0\.1\.1/d' /etc/hosts
 echo "127.0.1.1 $HOSTNAME.b8.nz $HOSTNAME" | sudo tee -a /etc/hosts
 
 
+##### exit first stage if running as root
 if [[ $EUID == 0 ]]; then
     echo "$0: running as root. exiting now that users are setup"
     exit 0
 fi
 
 
-#### begin link bashrc for root ######
+#### setup bash for root
 for x in /a/c/{.bashrc,brc,.bash_profile,.profile,.inputrc,path_add_function}; do
     sudo -i <<EOF
 PATH="/a/exe:$PATH"
 lnf $x /root
 EOF
 done
-#### end link bashrc repo for root ######
 
+###### do conflink
 # li needs the bind group before conflink
 if [[ $HOSTNAME == li ]]; then
     getent group bind &>/dev/null || sudo groupadd -r bind
@@ -201,6 +207,7 @@ fi
 # this needs to be before installing pacserve so we have gpg conf.
 conflink
 
+###### bash environment setup
 set +x
 errallow
 source /etc/profile.d/environment.sh
@@ -209,7 +216,7 @@ $interactive || errcatch
 $interactive || set -x
 
 
-# passwordless sudo
+#### setup passwordless sudo
 tu /etc/sudoers <<EOF
 $USER  ALL=(ALL)  NOPASSWD: ALL
 Defaults  env_keep += SUDOD
@@ -219,28 +226,24 @@ Defaults always_set_home
 EOF
 
 
-# enable magic sysrq keys. debian docs say it is already enabled by default
-isfedora && tu /etc/sysctl.conf 'kernel.sysrq = 1'
-
-
-if isdeb; then
-    codename=$(debian-codename)
-    ## ian: disabled. backports are not being published atm due to rust packaging issue
-    #     if isdebian-stable && has_x; then
-    #         s dd of=/etc/apt/sources.list.d/mozilla-iceweasel.list <<EOF
-    # deb http://mozilla.debian.net/ $codename-backports firefox-release
-    # deb-src http://mozilla.debian.net/ $codename-backports firefox-release
-    # EOF
-    #         p update
-    #         # take care of mozilla signing errors in previous command
-    #         pi pkg-mozilla-archive-keyring
-    #     fi
-    p update
-
-fi
+#### setup firefox backport
+## ian: disabled. backports are not being published atm due to rust packaging issue
+# if isdeb; then
+#     codename=$(debian-codename)
+#         if isdebian-stable && has_x; then
+#             s dd of=/etc/apt/sources.list.d/mozilla-iceweasel.list <<EOF
+#     deb http://mozilla.debian.net/ $codename-backports firefox-release
+#     deb-src http://mozilla.debian.net/ $codename-backports firefox-release
+# EOF
+#             p update
+#             # take care of mozilla signing errors in previous command
+#             pi pkg-mozilla-archive-keyring
+#         fi
+#     p update
+# fi
 
 
-###### begin arch aur wrapper ########
+######  arch aur wrapper setup
 if isarch; then
     #https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages
     sudo pacman -S --noconfirm --needed base-devel jq
@@ -267,24 +270,24 @@ if isarch; then
     sudo systemctl start pacserve.service
 
 fi
-###### end arch aur wrapper ########
 
+#### update all packages
 pup
 
 
-###### begin trash cli install ######
+###### p1 packages install ######
 if isarch; then
-    # strange error if just installing trash-cli: "pyalpm requires python",
+    # requirement for trash-cli.
+    # background: strange error if just installing trash-cli: "pyalpm requires python",
     # so I see that it requires python2, and installing that manually fixes it.
     # I didn\'t see this on earlier installation, main thing which changed was
     # pacserve, so not sure if it\'s related.
     pi python2
 fi
-pi trash-cli
-###### end trash cli install ######
+pi ${p1[@]}
 
 
-######## begin fix evbug bug ######
+######## fix evbug bug ######
 case $distro in
     trisquel|ubuntu)
         # noticed in flidas.
@@ -302,40 +305,24 @@ case $distro in
         fi
         ;;
 esac
-######## end fix evbug bug ######
-
 
 
-###### begin link files ###########
+###### link files
 # convenient to just do all file linking in one place
-
-
 s lnf -T /a/bin /b
 s lnf -T /nocow/t /t
-
 if has_p; then
     lnf -T /p/News ~/News
 fi
-
 s lnf /q/root/.editor-backups /q/root/.undo-tree-history \
   /a/opt /a/c/.emacs.d $HOME/mw_vars /k/backup /root
-
 rootsshsync
-
 s lnf /a/c/.vim /a/c/.vimrc /a/c/.gvimrc /root
-
-# machine is going away
-# if [[ $HOSTNAME == htpc ]]; then
-#     lnf -T /i/Videos ~/Downloads
-# fi
-
 if has_p; then
     # for dovecot
     lnf -T /i/k/mboxes ~/mail
 fi
 
-###### end link files ###########
-
 
 ##### basic needed packages
 
@@ -534,8 +521,6 @@ if has_x; then
 fi
 ### end setup for keyboard and redshift ###
 
-
-pi cryptsetup lvm2
 # enables trim for volume delete, other rare commands.
 sudo $sed -ri 's/( *issue_discards\b).*/\1 = 1/' /etc/lvm/lvm.conf
 
@@ -757,19 +742,16 @@ EOF
     fi
 
 
-    pi ghc sakura
+    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
-    pi cabal-install
     cabal update
     PATH="$PATH:$HOME/.cabal/bin"
 
     # todo, on older ubuntu I used cabal xmonad + xfce,
     # see /a/bin/old-unused/xmonad-cabal.sh
 
-    # trying out the distros versions newer distros
-    pi xmonad
     if isarch; then
         # for displaying error messages.
         # optional dependency in arch, standard elsewhere.
index 81174b466a42b8e79f84b5116d2c85fbe94641d8..660d556ea2363d9220ab9859c09fc3d2b4403f97 100755 (executable)
@@ -22,6 +22,8 @@ echo "$0: $(date): starting now)"
 
 src="${BASH_SOURCE%/*}"
 
+source $src/pkgs
+
 # see example of usage to understand.
 end_msg() {
     local y
@@ -43,136 +45,16 @@ case $distro in
 esac
 
 pup
-pi aptitude
-
-simple_packages=(
-    htop
-    iptables
-    mailutils
-    nmon
-    rdiff-backup
-    ruby
-    ruby-rest-client
-    tree
-    vim
-    wcd
-    wget
-)
+if isdeb; then
+    pi aptitude
+fi
+
+simple_packages=(${p3[@]})
 
 case $HOSTNAME in
     lj|li) : ;;
     *)
-        # universal packages
-        # swh-plugins is for karaoke pulsaudio filter.
-        # mutagen for pithos
-        # guvcview set webcam brightness to highest
-        # 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
-        simple_packages+=(
-            adb
-            apache2
-            apache2-doc
-            apt-doc
-            apt-listchanges
-            aptitude-doc-en
-            bash-doc
-            beets
-            beets-doc
-            binutils-doc
-            bind9-doc
-            bind9utils
-            bwm-ng
-            cloc
-            cpulimit
-            cron
-            debootstrap
-            debconf-doc
-            dirmngr
-            dnsutils
-            dnsmasq
-            dtrx
-            duplicity
-            eclipse
-            evince
-            fdupes
-            feh
-            filelight
-            flashrom
-            gawk-doc
-            gcc-doc
-            gdb
-            gdb-doc
-            geoip-bin
-            git-doc
-            git-email
-            gitk
-            glibc-doc
-            goaccess
-            gnome-screenshot
-            guvcview
-            i3lock
-            inetutils-traceroute
-            iperf3
-            iproute2-doc
-            jq
-            kid3-qt
-            kid3-cli
-            konsole
-            libreoffice
-            linphone
-            linux-doc
-            locate
-            lshw
-            make-doc
-            manpages
-            manpages-dev
-            mb2md
-            meld
-            mps-youtube
-            mpv
-            mumble
-            nagstamon
-            ncdu
-            nginx-doc
-            nmap
-            offlineimap
-            oathtool
-            opendkim-tools
-            p7zip
-            paprefs
-            parted-doc
-            pavucontrol
-            pdfgrep
-            perl-doc
-            pianobar
-            pidgin
-            pidgin-otr
-            pry
-            python-autopep8
-            python3-doc
-            qrencode
-            reportbug
-            $(aptitude show ruby | sed -rn 's/Depends: (.*)/\1/p')-doc
-            schroot
-            sqlite3-doc
-            squashfs-tools
-            swh-plugins
-            tar-doc
-            tcpdump
-            telnet
-            transmission-remote-gtk
-            vlc
-            whois
-            wondershaper
-            xawtv
-            xbacklight
-            xprintidle
-            xscreensaver
-            xscreensaver-data-extra
-            xscreensaver-gl
-            xscreensaver-gl-extra
-        )
+        simple_packages+=(${p4[@]})
         spa $(apt-cache search ruby[.0-9]+-doc| awk '{print $1}')
         ;;
 esac
@@ -719,6 +601,7 @@ EOF
         # todo: figure out how to make playback in erc happe.n
         s useradd --create-home -d /var/lib/znc --system --shell /sbin/nologin --comment "Account to run ZNC daemon" --user-group znc || [[ $? == 9 ]] # 9 if it exists already
         chmod 700 /var/lib/znc
+        s chown -R znc:znc /var/lib/znc/config
         s dd of=/etc/systemd/system/znc.service 2>/dev/null <<'EOF'
 [Unit]
 Description=ZNC, an advanced IRC bouncer
index fa210235f5b9835cbbd7bd9367bf1b50ba55aec8..23adf30106ced2c8e712688afadf053a67c3e518 100644 (file)
@@ -1,10 +1,6 @@
+#!/bin/bash
+
 # no screensaver for htpc machine
 if [[ $HOSTNAME != frodo ]]; then
 /usr/share/xscreensaver/xscreensaver-wrapper.sh &
 fi
-
-/a/exe/lnf -T /p/arbtt-capture.log ~/.arbtt/capture.log
-
-# docs say a sample rate less than 20 is probably not worth the data cost,
-# but it seems pretty small to me
-arbtt-capture --sample-rate=10 &
index 95dce05679534846aad55c42eff9b722136822d5..4c5794f4fc918219cc18131e9e5e22f3f0f14f0e 100644 (file)
@@ -55,16 +55,20 @@ if [ -f /etc/fedora-release ]; then
     fi
 fi
 
+# background:
 # ubuntu has 002 for non-system users, debian has 022.  002 makes groups
-# be rw instead of r. One security concern is where some unixes put
-# every user in a same group, so if you copy files there with exact
-# perms, that is probably not what you want. I don't use a system like
-# that. I don't care much either way, but the ubuntu one seems a bit
-# more user friendly, and copying files between them is a annoying with
-# different umasks. However, it also makes it so if you create a file as
-# a regular user then move it to become a system file, it's got slightly
-# wrong permissions, and sometimes thing break. So, this outweighs the
-# other things, stick with 022 umask always.
+# be rw instead of r.
+#
+# ubuntu is more user friendly when using multiple users. However,
+# it also makes it so if you create a file as a regular user then move
+# it to become a system file, it's got slightly wrong permissions, and
+# sometimes thing break. Also, copying files between ubuntu and debian
+# makes things inconsistent. So stick with 022 umask always.
+#
+# One security concern is where some unixes put every user in a same
+# group, so if you copy files there with exact perms, that is probably
+# not what you want. I don't use a system like that, so I don't
+# care.
 umask 022
 # this is how we could test for non-system user
 
index 930ddcca0edd3b4d5dfd2d88c9e4407e3f006fad..c7f29337e30eeb11777b8f5b3fecd4f5c5995876 100755 (executable)
@@ -117,6 +117,7 @@ u=$SUDO_USER
 # echo "dmarc dns, name: _dmarc value: v=DMARC1; p=none; rua=mailto:mailauth-reports@$domain"
 
 # # 2017-02 spf policies:
+# # host -t txt lists.fedoraproject.org
 # # google ~all, hotmail -all, yahoo: ?all, fastmail ?all
 # # i include fastmail\'s settings, per their instructions,
 # # and follow their policy. In mail in a box, or similar instructions,
diff --git a/pkgs b/pkgs
new file mode 100644 (file)
index 0000000..524849e
--- /dev/null
+++ b/pkgs
@@ -0,0 +1,138 @@
+#!/bin/bash
+# meant to be sourced
+
+p1=(
+    trash-cli
+    cryptsetup
+    lvm2
+)
+p2=(
+    # 2nd
+    ghc
+    sakura
+    xmonad
+    cabal-install
+)
+p3=(
+    htop
+    iptables
+    mailutils
+    nmon
+    rdiff-backup
+    ruby
+    ruby-rest-client
+    tree
+    vim
+    wcd
+    wget
+)
+
+# swh-plugins is for karaoke pulsaudio filter.
+# mutagen for pithos
+# guvcview set webcam brightness to highest
+# 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
+p4=(
+    adb
+    apache2
+    apache2-doc
+    apt-doc
+    apt-listchanges
+    aptitude-doc-en
+    bash-doc
+    beets
+    beets-doc
+    binutils-doc
+    bind9-doc
+    bind9utils
+    bwm-ng
+    cloc
+    cpulimit
+    cron
+    debootstrap
+    debconf-doc
+    dirmngr
+    dnsutils
+    dnsmasq
+    dtrx
+    duplicity
+    eclipse
+    evince
+    fdupes
+    feh
+    filelight
+    flashrom
+    gawk-doc
+    gcc-doc
+    gdb
+    gdb-doc
+    geoip-bin
+    git-doc
+    git-email
+    gitk
+    glibc-doc
+    goaccess
+    gnome-screenshot
+    guvcview
+    i3lock
+    inetutils-traceroute
+    iperf3
+    iproute2-doc
+    jq
+    kid3-qt
+    kid3-cli
+    konsole
+    libreoffice
+    linphone
+    linux-doc
+    locate
+    lshw
+    make-doc
+    manpages
+    manpages-dev
+    mb2md
+    meld
+    mps-youtube
+    mpv
+    mumble
+    nagstamon
+    ncdu
+    nginx-doc
+    nmap
+    offlineimap
+    oathtool
+    opendkim-tools
+    p7zip
+    paprefs
+    parted-doc
+    pavucontrol
+    pdfgrep
+    perl-doc
+    pianobar
+    pidgin
+    pidgin-otr
+    pry
+    python-autopep8
+    python3-doc
+    qrencode
+    reportbug
+    schroot
+    sqlite3-doc
+    squashfs-tools
+    swh-plugins
+    tar-doc
+    tcpdump
+    telnet
+    transmission-remote-gtk
+    vlc
+    whois
+    wondershaper
+    xawtv
+    xbacklight
+    xprintidle
+    xscreensaver
+    xscreensaver-data-extra
+    xscreensaver-gl
+    xscreensaver-gl-extra
+)
index 9315807d6ca00196574a06d967158c951f7becfc..9b4872db4b189c56245a3d31746976e027e855b9 100755 (executable)
@@ -218,6 +218,6 @@ if $restore_old_btrbk; then
     $old_shell sudo systemctl start btrbk.timer
 fi
 
-$new_shell arbtt-capture --sample-rate=10 &
+$new_shell DISPLAY=:0 arbtt-capture --sample-rate=10 &
 
 echo $warn