home · contact · privacy
Improve automatic go setup in postinstall script.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 8 Feb 2016 01:21:19 +0000 (02:21 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 8 Feb 2016 01:21:19 +0000 (02:21 +0100)
jessie_postinstall.sh
setup_go.sh

index 1fd90859c79145612079e7eb484240ff20d38d51..4527374eeb524d55e4b16bdc1294130cb92286cf 100755 (executable)
@@ -215,17 +215,16 @@ if [ "$1" = "server" ]; then
         # Send instructions mail.
         config/bin/simplemail.sh config/mails/server_postinstall_finished
     elif [ "$2" = "public" ]; then
-        apt-get -y install sudo
-        adduser plom sudo
         su plom -c '~/config/setup_go.sh '\
-            'https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz'
+'https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz'
         su plom -c 'git clone '\
             'https://github.com/plomlompom/htwtxt $GOPATH/src/htwtxt'
         su plom -c 'go get htwtxt'
         su plom -c 'mkdir ~/htwtxt'
         su plom -c 'cp -R $GOPATH/src/htwtxt/templates ~/htwtxt'
-        deluser plom sudo
-        apt-get -y --purge autoremove sudo
+        cp config/systemfiles/htwtxt.service \
+            /etc/systemd/system/htwtxt.service
+        systemctl enable /etc/systemd/system/htwtxt.service
     fi
 
 elif [ "$1" = "thinkpad" ]; then
index 4d255f8f58cfef0fa5bc93b87df3cbaefdde1f19..0d27fc3ce962b145042e87c7de58031c8eb1840a 100755 (executable)
@@ -3,6 +3,10 @@
 set -e
 set -x
 
+url=$1
+user=plom
+users_home=`su $user -s /bin/sh -c 'echo ~'`
+
 ensure_line() {
     add_string="$1"
     file="$2"
@@ -14,22 +18,22 @@ ensure_line() {
 
 filename=temp_golang_binary
 
-if [ "$1" = "" ]; then
+if [ "$url" = "" ]; then
     echo 'Need URL of current go package'
     exit 1
 fi
-sudo rm -rf /usr/local/go
-sudo apt-get -y install wget
-wget -O $filename $1
-sudo tar -C /usr/local -xzf $filename
+rm -rf /usr/local/go
+apt-get -y install wget
+wget -O $filename $url
+tar -C /usr/local -xzf $filename
 rm $filename
-ensure_line 'export PATH=$PATH:/usr/local/go/bin' ~/.shinit_add
-ensure_line 'export GOPATH=~/gopath' ~/.shinit_add
-sudo apt-get -y install vim-pathogen
-rm -rf ~/.vim/bundle/vim-go
-git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go
-ensure_line 'source ~/.vimrc_vimgo' ~/.vimrc_add
-cat << EOF > ~/.vimrc_vimgo
+ensure_line 'export PATH=$PATH:/usr/local/go/bin' $users_home/.shinit_add
+ensure_line 'export GOPATH=~/gopath' $users_home/.shinit_add
+apt-get -y install vim-pathogen
+rm -rf $users_home/.vim/bundle/vim-go
+su $user -s 'git clone https://github.com/fatih/vim-go.git ~/.vim/bundle/vim-go'
+ensure_line 'source ~/.vimrc_vimgo' $users_home/.vimrc_add
+cat << EOF > $users_home/.vimrc_vimgo
 " vim-go: Make vim-go run.
 call pathogen#infect()
 let g:go_disable_autoinstall = 0
@@ -40,3 +44,5 @@ let g:go_highlight_structs = 1
 let g:go_highlight_operators = 1
 let g:go_highlight_build_constraints = 1
 EOF
+chown $user $users_home/.vimrc_vimgo
+chgrp $user $users_home/.vimrc_vimgo