various fixes
[distro-setup] / distro-end
index 4056d055a125deda49ac4aa47081086580454864..3ebc231f1510932151f88ad263380034d2888de7 100755 (executable)
@@ -6,6 +6,9 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
 
 set -x
 
+exec &> >(sudo tee -a /var/log/distro-end)
+echo "$0: $(date): starting now)"
+
 end_msg() {
     =    local y
     IFS= read -r -d '' y  ||:
@@ -14,6 +17,7 @@ end_msg() {
 
 distro=$(distro-name)
 
+pending_reboot=false
 
 # template
 case $distro in
@@ -46,6 +50,7 @@ simple_packages=(
     smartmontools
     squashfs-tools
     tcpdump
+    transmission-remote-gtk
     tree
     vim
 )
@@ -160,21 +165,29 @@ EOF
     esac
 fi
 
-# from /var/lib/dpkg/info/transmission-daemon.postinst
+# adapted from /var/lib/dpkg/info/transmission-daemon.postinst
 if ! getent passwd debian-transmission > /dev/null; then
-    s adduser --quiet \
-      --system \
-      --group \
-      --no-create-home \
-      --disabled-password \
-      --home /var/lib/transmission-daemon \
-      debian-transmission
+    case $distro in
+        arch)
+            s useradd \
+              --system \
+              --create-home \
+              --home-dir /var/lib/transmission-daemon \
+              --shell /bin/false \
+              debian-transmission
+            ;;
+        *)
+            s adduser --quiet \
+              --system \
+              --group \
+              --no-create-home \
+              --disabled-password \
+              --home /var/lib/transmission-daemon \
+              debian-transmission
+            ;;
+    esac
 fi
 
-case $distro in
-    debian|ubuntu) pi transmission-remote-gtk ;;
-    arch) pi transmission-remote-gtk2 ;;
-esac
 # arch had a default config,
 # debian had nothing until you start it.
 # With a little trial an error, here is a minimal config
@@ -227,46 +240,46 @@ case $distro in
         ser disable openvpn@client
         ser disable openvpn
         ;;
-    *) pi openvpn ;;
-esac
+        *) pi openvpn ;;
+    esac
 
-case $HOSTNAME in
-    tp|frodo)
-        case $distro in
-            debian|ubuntu)
-                log=$(mktemp)
-                cd /a/opt
-                wget -N https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
-                set +e
-                s dpkg -i google-chrome-stable_current_amd64.deb &> $log
-                code=$?
-                set -e
-                case $code in
-                    1)
-                        if grep '^dpkg: dependency problems prevent configuration of' \
-                                $log &>/dev/null; then
-                            s apt-get -fy install
-                        else
-                            exit 1
-                        fi
-                        ;;
-                    0) : ;;
-                    *) exit $code
-                esac
-                ;;
-            arch)
-                pi google-chrome
-                ;;
-        esac
-        ;;
-esac
+    case $HOSTNAME in
+        tp|frodo)
+            case $distro in
+                debian|ubuntu)
+                    log=$(mktemp)
+                    cd /a/opt
+                    wget -N https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
+                    set +e
+                    s dpkg -i google-chrome-stable_current_amd64.deb &> $log
+                    code=$?
+                    set -e
+                    case $code in
+                        1)
+                            if grep '^dpkg: dependency problems prevent configuration of' \
+                                    $log &>/dev/null; then
+                                s apt-get -fy install
+                            else
+                                exit 1
+                            fi
+                            ;;
+                        0) : ;;
+                        *) exit $code
+                    esac
+                    ;;
+                arch)
+                    pi google-chrome
+                    ;;
+            esac
+            ;;
+    esac
 
-case $distro in
-    # ubuntu unknown. probably the same as debian, just check if the
-    # init scripts come with the package.
-    debian)
-        # copied from arch
-        s dd of=/etc/systemd/system/synergys@.service <<'EOF'
+    case $distro in
+        # ubuntu unknown. probably the same as debian, just check if the
+        # init scripts come with the package.
+        debian)
+            # copied from arch, but moved to etc
+            s dd of=/etc/systemd/user/synergys.service <<'EOF'
 [Unit]
 Description=Synergy Server Daemon
 After=network.target
@@ -279,7 +292,7 @@ Restart=on-failure
 [Install]
 WantedBy=multi-user.target
 EOF
-        s dd of=/etc/systemd/system/synergys@.socket <<'EOF'
+            s dd of=/etc/systemd/user/synergys.socket <<'EOF'
 [Unit]
 Conflicts=synergys@.service
 
@@ -290,10 +303,11 @@ Accept=false
 [Install]
 WantedBy=sockets.target
 EOF
-        ;;&
-    *)
-        pi synergy
-        s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
+            ;;&
+        *)
+            pi synergy
+            # taken from arch wiki.
+            s dd of=/etc/systemd/system/synergyc@.service <<'EOF'
 [Unit]
 Description=Synergy Client
 After=network.target
@@ -310,146 +324,147 @@ RestartSec=3s
 [Install]
 WantedBy=multi-user.target
 EOF
-        case $HOSTNAME in
-            frodo)
-                sgo synergyc@ian
-                sgo synergys@ian.socket
-                ;;
-            treetowl) sgo synergys@ian.socket ;;
-        esac
-        ;;
-esac
+            case $HOSTNAME in
+                frodo)
+                    sgo synergyc@ian
+                    systemctl --user start synergys
+                    systemctl --user enable synergys
+                    ;;
+                treetowl) systemctl --user enable synergys ;;
+            esac
+            ;;
+    esac
 
-case $distro in
-    # tk for gitk
-    arch) spa git tk ;;
-    *) spa git ;;
-esac
+    case $distro in
+        # tk for gitk
+        arch) spa git tk ;;
+        *) spa git ;;
+    esac
 
-case $distro in
-    arch) spa the_silver_searcher ;;
-    debian|ubuntu) spa silversearcher-ag ;;
-    # fedora unknown
-esac
+    case $distro in
+        arch) spa the_silver_searcher ;;
+        debian|ubuntu) spa silversearcher-ag ;;
+        # fedora unknown
+    esac
 
-# printer
-case $distro in
-    arch)
-        pi cups ghostscript gsfonts # from arch wiki cups page
-        pi hplip # from google
-        s gpasswd -a $USER sys # from arch wiki
-        sgo org.cups.cupsd.service
-        # goto http://127.0.0.1:631
-        # administration tab, add new printer button.
-        # In debian, I could use hte recommended driver,
-        # in arch, I had to pick out the 6L driver.
-        ;;
-    debian|ubuntu)
-        spa hplip
-        ;;
-    # other distros unknown
-esac
+    # printer
+    case $distro in
+        arch)
+            pi cups ghostscript gsfonts # from arch wiki cups page
+            pi hplip # from google
+            s gpasswd -a $USER sys # from arch wiki
+            sgo org.cups.cupsd.service
+            # goto http://127.0.0.1:631
+            # administration tab, add new printer button.
+            # In debian, I could use hte recommended driver,
+            # in arch, I had to pick out the 6L driver.
+            ;;
+        debian|ubuntu)
+            spa hplip
+            ;;
+        # other distros unknown
+    esac
 
 
-case $distro in
-    ubuntu|debian) spa ack-grep ;;
-    arch|fedora) spa ack ;;
-    # fedora unknown
-esac
-case $distro in
-    ubuntu|debian) pi --no-install-recommends mairix notmuch ;;
-    fedora|arch) spa mairix notmuch ;;
-esac
-case $distro in
-    arch) spa nfs-utils ;;
-    ubuntu|debian) spa nfs-client ;;
-esac
-case $distro in
-    ubuntu|debian) spa par2 ;;
-    arch|fedora) spa par2cmdline ;;
-esac
+    case $distro in
+        ubuntu|debian) spa ack-grep ;;
+        arch|fedora) spa ack ;;
+        # fedora unknown
+    esac
+    case $distro in
+        ubuntu|debian) pi --no-install-recommends mairix notmuch ;;
+        fedora|arch) spa mairix notmuch ;;
+    esac
+    case $distro in
+        arch) spa nfs-utils ;;
+        ubuntu|debian) spa nfs-client ;;
+    esac
+    case $distro in
+        ubuntu|debian) spa par2 ;;
+        arch|fedora) spa par2cmdline ;;
+    esac
 
-# needed for my tex resume
-case $distro in
-    ubuntu|debian) spa texlive-full ;;
-    arch) spa texlive-most ;;
-    # fedora unknown
-esac
+    # needed for my tex resume
+    case $distro in
+        ubuntu|debian) spa texlive-full ;;
+        arch) spa texlive-most ;;
+        # fedora unknown
+    esac
 
-case $distro in
-    ubuntu)
-        # flash, unrar, codecs, ms fonts.
-        # This has a manual prompt.
-        spa ubuntu-restricted-extras
-        ;;
-    fedora)
-        pi yum-utils
-        # rpm fusion recommended codecs
-        s su -c "yum localinstall -y --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm"
-        pi gstreamer-plugins-ugly gstreamer-plugins-bad gstreamer-ffmpeg\
-           xine-lib-extras-freeworld
-        ;;
-esac
+    case $distro in
+        ubuntu)
+            # flash, unrar, codecs, ms fonts.
+            # This has a manual prompt.
+            spa ubuntu-restricted-extras
+            ;;
+        fedora)
+            pi yum-utils
+            # rpm fusion recommended codecs
+            s su -c "yum localinstall -y --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm"
+            pi gstreamer-plugins-ugly gstreamer-plugins-bad gstreamer-ffmpeg\
+               xine-lib-extras-freeworld
+            ;;
+    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
+        # optional dep for firefox for h.264 video
+        arch) spa gst-libav ;;
+        # other distros, probably come by default
+    esac
 
-case $distro in
-    fedora|ubuntu|debian) spa gnupg-agent ;;
-    arch) : ;;
-esac
+    case $distro in
+        fedora|ubuntu|debian) spa gnupg-agent ;;
+        arch) : ;;
+    esac
 
 
-case $distro in
-    fedora) spa pinentry-gtk ;;
-    *) : ;; # comes default or with other packages
-esac
+    case $distro in
+        fedora) spa pinentry-gtk ;;
+        *) : ;; # comes default or with other packages
+    esac
 
-case $distro in
-    arch) spa firefox pulseaudio;;
-    *) : ;; # comes default or with other packages
-esac
+    case $distro in
+        arch) spa firefox pulseaudio;;
+        *) : ;; # comes default or with other packages
+    esac
 
-case $distro in
-    arch|debian|ubuntu)
-        spa bash-completion
-        ;;
-    # others unknown
-esac
+    case $distro in
+        arch|debian|ubuntu)
+            spa bash-completion
+            ;;
+        # others unknown
+    esac
 
 
-case $distro in
-    arch) spa ttf-dejavu;;
-    debian|ubuntu) spa fonts-dejavu ;;
-    # others unknown
-esac
+    case $distro in
+        arch) spa ttf-dejavu;;
+        debian|ubuntu) spa fonts-dejavu ;;
+        # others unknown
+    esac
 
-case $distro in
-    debian|ubuntu) spa ntp;;
-    arch)
-        pi ntp
-        sgo ntpd
-        ;;
-    # others unknown
-esac
+    case $distro in
+        debian|ubuntu) spa ntp;;
+        arch)
+            pi ntp
+            sgo ntpd
+            ;;
+        # others unknown
+    esac
 
-case $distro in
-    arch) spa xorg-xev;;
-    debian|ubuntu) spa x11-utils ;;
-    # others unknown
-esac
+    case $distro in
+        arch) spa xorg-xev;;
+        debian|ubuntu) spa x11-utils ;;
+        # others unknown
+    esac
 
-case $distro in
-    arch) pi virt-install;;&
-    debian|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 ian traci; do s usermod -a -G libvirt $x; done
+    case $distro in
+        arch) pi virt-install;;&
+        debian|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 ian traci; do s usermod -a -G libvirt $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
@@ -478,9 +493,10 @@ esac
 case $distro in
     arch)
         # cdrkit for cloud-init isos
-        # dnsmasq for nat networking in libvirt
+        # dnsmasq & ebtables for nat networking in libvirt
         # qemu for qemu-img, bind-tools for dig
-        pi unzip wget xorg-xmodmap \
+        # dmidecode just because syslog complains
+        pi unzip wget 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.
@@ -489,7 +505,10 @@ case $distro in
         # https://bbs.archlinux.org/viewtopic.php?id=206206
         # # this should prolly go in the wiki
         sgo virtlogd.socket
-        sgo virtlogd.service
+        # guessing this is not needed
+        #sgo virtlogd.service
+        sgo libvirtd
+
         ;;
 esac
 
@@ -514,7 +533,7 @@ case $distro in
         pi cronie
         sgo cronie
         ;;
-                        *) : ;; # other distros come with cron.
+                            *) : ;; # other distros come with cron.
 esac
 
 
@@ -746,8 +765,8 @@ if [[ ! -L /var/spool/postfix ]]; then
     ser stop postfix
     n=/q/postfix-`distro-name``debian-archive`
     if [[ -e $n ]]; then
-        echo "$0: error: /q/postfix exists but not the link to it"
-        exit 1
+        echo "$0: warning: $n already exists before we do the link, removing it"
+        rm -rf $n
     fi
     s mv /var/spool/postfix $n
     s lnf -T $n /var/spool/postfix
@@ -885,8 +904,9 @@ EOF
         pi nfs-server
         ;;
     arch)
-        pi nfs-utils
+        pi nfs-utils || pending_reboot=true
         sgo rpcbind
+        # this failed until I rebooted
         sgo nfs-server
         ;;
 esac
@@ -975,7 +995,9 @@ fi
 
 pi samba
 # note samba re-reads it's config every 1 minute
-
+case $distro in
+    arch) s cp /etc/samba/smb.conf.default /etc/samba/smb.conf ;;
+esac
 
 # add 2 lines after workgroup option
 s sed -ri '/^\s*encrypt passwords\s*=/d' /etc/samba/smb.conf
@@ -1029,3 +1051,10 @@ fi
 # Do this again because it occasionally has changes and
 # it can be run outside initial isntall.
 s /a/bin/fai/fai/config/distro-install-common/end
+
+if $pending_reboot; then
+    echo "$0: pending reboot and then finished. doing it now."
+    s reboot now
+else
+    echo "$0: $(date): ending now)"
+fi