From a6ea23c10570e9f82472212c4e566596fcb0b803 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 8 Feb 2016 01:03:18 +0100
Subject: [PATCH] Restructure symlinks, add new server type postinstall.

---
 bin/symlink.sh                                | 14 +++++++++--
 dotfiles/user/server/{ => minimal}/mailfilter |  0
 dotfiles/user/server/{ => minimal}/muttrc     |  0
 .../{ => personal/minimal}/getmail/getmailrc  |  0
 .../server/{ => personal/minimal}/procmailrc  |  0
 .../server/{ => personal/minimal}/shinit_add  |  0
 .../server/{ => personal/minimal}/weechatrc   |  0
 .../personal}/plomlompom.com/shinit_color     |  0
 .../test.plomlompom.com/shinit_color          |  0
 dotfiles/user/server/public/shinit_color      |  1 +
 .../{ => thinkpad}/T450s/Xresources-local     |  0
 .../user/{ => thinkpad}/T450s/i3status.conf   |  0
 .../{ => thinkpad}/X200s/Xresources-local     |  0
 .../user/{ => thinkpad}/X200s/i3status.conf   |  0
 .../user/thinkpad/{ => minimal}/Xresources    |  0
 .../user/thinkpad/{ => minimal}/i3/config     |  0
 .../user/thinkpad/{ => minimal}/pentadactylrc |  0
 .../user/thinkpad/{ => minimal}/shinit_color  |  0
 dotfiles/user/thinkpad/{ => minimal}/xinitrc  |  0
 jessie_postinstall.sh                         | 24 +++++++++++--------
 20 files changed, 27 insertions(+), 12 deletions(-)
 rename dotfiles/user/server/{ => minimal}/mailfilter (100%)
 rename dotfiles/user/server/{ => minimal}/muttrc (100%)
 rename dotfiles/user/server/{ => personal/minimal}/getmail/getmailrc (100%)
 rename dotfiles/user/server/{ => personal/minimal}/procmailrc (100%)
 rename dotfiles/user/server/{ => personal/minimal}/shinit_add (100%)
 rename dotfiles/user/server/{ => personal/minimal}/weechatrc (100%)
 rename dotfiles/user/{ => server/personal}/plomlompom.com/shinit_color (100%)
 rename dotfiles/user/{ => server/personal}/test.plomlompom.com/shinit_color (100%)
 create mode 100644 dotfiles/user/server/public/shinit_color
 rename dotfiles/user/{ => thinkpad}/T450s/Xresources-local (100%)
 rename dotfiles/user/{ => thinkpad}/T450s/i3status.conf (100%)
 rename dotfiles/user/{ => thinkpad}/X200s/Xresources-local (100%)
 rename dotfiles/user/{ => thinkpad}/X200s/i3status.conf (100%)
 rename dotfiles/user/thinkpad/{ => minimal}/Xresources (100%)
 rename dotfiles/user/thinkpad/{ => minimal}/i3/config (100%)
 rename dotfiles/user/thinkpad/{ => minimal}/pentadactylrc (100%)
 rename dotfiles/user/thinkpad/{ => minimal}/shinit_color (100%)
 rename dotfiles/user/thinkpad/{ => minimal}/xinitrc (100%)

diff --git a/bin/symlink.sh b/bin/symlink.sh
index 5f4fc81..49a1161 100755
--- a/bin/symlink.sh
+++ b/bin/symlink.sh
@@ -6,8 +6,13 @@ set -e
 dir_minimal=~/config/dotfiles/minimal
 dir_user_prefix=~/config/dotfiles/user
 dir_user_minimal=$dir_user_prefix/minimal
-dir_user_machine=$dir_user_prefix/$1
-dir_user_variety=$dir_user_prefix/$2
+dir_user_machine=$dir_user_prefix/$1/minimal
+if [ "$3" = "" ]; then
+    dir_user_variety=$dir_user_machine/$2
+else
+    dir_user_variety=$dir_user_machine/$2/minimal
+fi
+dir_user_subvariety=$dir_user_variety/$3
 dir_root=~/config/dotfiles/root
 homedir=`echo ~`
 find ~ -lname $homedir'/config/*' -delete
@@ -28,4 +33,9 @@ else
     for file in `ls $dir_user_variety`; do
         ln -fs $dir_user_variety/$file ~/.$file
     done
+    if [ ! "$3" = "" ]; then
+        for file in `ls $dir_user_subvariety`; do
+            ln -fs $dir_user_subvariety/$file ~/.$file
+        done
+    fi
 fi
diff --git a/dotfiles/user/server/mailfilter b/dotfiles/user/server/minimal/mailfilter
similarity index 100%
rename from dotfiles/user/server/mailfilter
rename to dotfiles/user/server/minimal/mailfilter
diff --git a/dotfiles/user/server/muttrc b/dotfiles/user/server/minimal/muttrc
similarity index 100%
rename from dotfiles/user/server/muttrc
rename to dotfiles/user/server/minimal/muttrc
diff --git a/dotfiles/user/server/getmail/getmailrc b/dotfiles/user/server/personal/minimal/getmail/getmailrc
similarity index 100%
rename from dotfiles/user/server/getmail/getmailrc
rename to dotfiles/user/server/personal/minimal/getmail/getmailrc
diff --git a/dotfiles/user/server/procmailrc b/dotfiles/user/server/personal/minimal/procmailrc
similarity index 100%
rename from dotfiles/user/server/procmailrc
rename to dotfiles/user/server/personal/minimal/procmailrc
diff --git a/dotfiles/user/server/shinit_add b/dotfiles/user/server/personal/minimal/shinit_add
similarity index 100%
rename from dotfiles/user/server/shinit_add
rename to dotfiles/user/server/personal/minimal/shinit_add
diff --git a/dotfiles/user/server/weechatrc b/dotfiles/user/server/personal/minimal/weechatrc
similarity index 100%
rename from dotfiles/user/server/weechatrc
rename to dotfiles/user/server/personal/minimal/weechatrc
diff --git a/dotfiles/user/plomlompom.com/shinit_color b/dotfiles/user/server/personal/plomlompom.com/shinit_color
similarity index 100%
rename from dotfiles/user/plomlompom.com/shinit_color
rename to dotfiles/user/server/personal/plomlompom.com/shinit_color
diff --git a/dotfiles/user/test.plomlompom.com/shinit_color b/dotfiles/user/server/personal/test.plomlompom.com/shinit_color
similarity index 100%
rename from dotfiles/user/test.plomlompom.com/shinit_color
rename to dotfiles/user/server/personal/test.plomlompom.com/shinit_color
diff --git a/dotfiles/user/server/public/shinit_color b/dotfiles/user/server/public/shinit_color
new file mode 100644
index 0000000..1e8b314
--- /dev/null
+++ b/dotfiles/user/server/public/shinit_color
@@ -0,0 +1 @@
+6
diff --git a/dotfiles/user/T450s/Xresources-local b/dotfiles/user/thinkpad/T450s/Xresources-local
similarity index 100%
rename from dotfiles/user/T450s/Xresources-local
rename to dotfiles/user/thinkpad/T450s/Xresources-local
diff --git a/dotfiles/user/T450s/i3status.conf b/dotfiles/user/thinkpad/T450s/i3status.conf
similarity index 100%
rename from dotfiles/user/T450s/i3status.conf
rename to dotfiles/user/thinkpad/T450s/i3status.conf
diff --git a/dotfiles/user/X200s/Xresources-local b/dotfiles/user/thinkpad/X200s/Xresources-local
similarity index 100%
rename from dotfiles/user/X200s/Xresources-local
rename to dotfiles/user/thinkpad/X200s/Xresources-local
diff --git a/dotfiles/user/X200s/i3status.conf b/dotfiles/user/thinkpad/X200s/i3status.conf
similarity index 100%
rename from dotfiles/user/X200s/i3status.conf
rename to dotfiles/user/thinkpad/X200s/i3status.conf
diff --git a/dotfiles/user/thinkpad/Xresources b/dotfiles/user/thinkpad/minimal/Xresources
similarity index 100%
rename from dotfiles/user/thinkpad/Xresources
rename to dotfiles/user/thinkpad/minimal/Xresources
diff --git a/dotfiles/user/thinkpad/i3/config b/dotfiles/user/thinkpad/minimal/i3/config
similarity index 100%
rename from dotfiles/user/thinkpad/i3/config
rename to dotfiles/user/thinkpad/minimal/i3/config
diff --git a/dotfiles/user/thinkpad/pentadactylrc b/dotfiles/user/thinkpad/minimal/pentadactylrc
similarity index 100%
rename from dotfiles/user/thinkpad/pentadactylrc
rename to dotfiles/user/thinkpad/minimal/pentadactylrc
diff --git a/dotfiles/user/thinkpad/shinit_color b/dotfiles/user/thinkpad/minimal/shinit_color
similarity index 100%
rename from dotfiles/user/thinkpad/shinit_color
rename to dotfiles/user/thinkpad/minimal/shinit_color
diff --git a/dotfiles/user/thinkpad/xinitrc b/dotfiles/user/thinkpad/minimal/xinitrc
similarity index 100%
rename from dotfiles/user/thinkpad/xinitrc
rename to dotfiles/user/thinkpad/minimal/xinitrc
diff --git a/jessie_postinstall.sh b/jessie_postinstall.sh
index 2d01b51..0a6fcf7 100755
--- a/jessie_postinstall.sh
+++ b/jessie_postinstall.sh
@@ -6,23 +6,27 @@ if [ ! "$1" = "thinkpad" ] && [ ! "$1" = "server" ]; then
     echo "Need argument."
     false
 fi
-
 if [ "$1" = "thinkpad" ] && [ ! "$2" = "X200s" ] && [ ! "$2" = "T450s" ]; then
     echo "Need Thinkpad type."
     false
 fi
-
-if [ "$1" = "server" ] && [ ! "$2" = "plomlompom.com" ] && \
-        [ ! "$2" = "test.plomlompom.com" ]; then
-    echo "Need server type."
+if [ "$1" = "server" ] && [ ! "$2" = "personal" ] && [ ! "$2" = "public" ]; then
+    echo "Need server purpose."
+    false
+fi
+if [ "$2" = "personal" ] && [ ! "$3" = "test.plomlompom.com" ] && \
+    [ ! "$3" = "plomlompom.com" ]; then
+    echo "Need server domain"
     false
 fi
 
 # Some important variables
-if [ "$2" = "plomlompom.com" ]; then
+if [ "$3" = "plomlompom.com" ]; then
     hostname="plomlompom"
-elif [ "$2" = "test.plomlompom.com" ]; then
+elif [ "$3" = "test.plomlompom.com" ]; then
     hostname="test.plomlompom"
+elif [ "$2" = "public" ]; then
+    hostname="twtxt.plomlompom"
 elif [ "$2" = "X200s" ]; then
     hostname="X220s"
 elif [ "$2" = "T450s" ]; then
@@ -58,7 +62,7 @@ hostname $hostname
 if [ "$1" = "server" ]; then
     echo '127.0.0.1 localhost' > /etc/hosts
     ip=`hostname -I | cut -d " " -f 1`
-    echo "$ip $2 $hostname" >> /etc/hosts
+    echo "$ip $hostname.com $hostname" >> /etc/hosts
 
     # Call dhclient on startup.
     cat > /etc/systemd/system/dhclient.service << EOF
@@ -153,7 +157,7 @@ config/bin/symlink.sh
 useradd -m -s /bin/bash plom
 rm -rf /home/plom/config
 su - plom -c 'git clone http://github.com/plomlompom/config /home/plom/config'
-su plom -c '/home/plom/config/bin/symlink.sh '$1' '$2
+su plom -c '/home/plom/config/bin/symlink.sh '$1' '$2' '$3
 
 # Allow user to sudo.
 if [ "$1" = "thinkpad" ]; then
@@ -182,7 +186,7 @@ if [ "$1" = "server" ]; then
     DEBIAN_FRONTEND=noninteractive apt-get -y install getmail4 procmail mutt \
         postfix maildrop
     cp config/systemfiles/main.cf /etc/postfix/main.cf
-    sed -i 's/HOSTNAME/'$2'/g' /etc/postfix/main.cf
+    sed -i 's/HOSTNAME/'$hostname.com'/g' /etc/postfix/main.cf
     cp config/systemfiles/aliases /etc/aliases
     newaliases
     service postfix restart
-- 
2.30.2