adding a script to ease the installation of Dyrcona's evergreen utilities
authorChris Sharp <csharp@georgialibraries.org>
Mon, 24 Feb 2014 13:00:33 +0000 (08:00 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Mon, 24 Feb 2014 13:00:33 +0000 (08:00 -0500)
setup_evergreen_utilities.sh [new file with mode: 0755]

diff --git a/setup_evergreen_utilities.sh b/setup_evergreen_utilities.sh
new file mode 100755 (executable)
index 0000000..e4e43ad
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+# A program to quickly download and configure Jason Stephenson's evergreen_utilities repo.
+
+EG_USER="admin"
+EG_PASS="gamma4pines"
+EG_WORKSTATION="STATELIB-L-csharp-desktop"
+APT_TOOL="/usr/bin/apt-get"
+GIT_USER="opensrf"
+GIT_HOME="/home/$GIT_USER"
+REPO_LIST="evergreen_utilities backstage JSONPrefs"
+BIN_DIR="$GIT_HOME/bin"
+LIB_DIR="$GIT_HOME/lib/perl"
+PREFS_DIR="$GIT_HOME/myprefs.d"
+DIR_LIST="$BIN_DIR $LIB_DIR $PREFS_DIR"
+EXPORT_PATH="export PATH=$PATH:$BIN_DIR"
+EXPORT_PERL5LIB="export PERL5LIB=$PERL5LIB:$LIBDIR"
+read -d '' EG_JSON <<EOF
+     {
+          "username" : "$EG_USER",
+          "password" : "$EG_PASS",
+          "workstation" : "$EG_WORKSTATION",
+          "type" : "staff"
+     }
+EOF
+
+
+if [ `whoami` != "root" ]; then
+       echo "Must be root to run this script."
+       exit 1;
+fi
+
+# install git if not installed
+$APT_TOOL install git
+
+# clone the desired repos
+for repo in $REPO_LIST; do 
+       su - $GIT_USER -c "git clone git://git.mvlcstaff.org/jason/$repo.git ~/$repo";
+done
+
+# create the expected directories
+for dir in $DIR_LIST; do 
+       if [ -d $dir ]; 
+               echo "$dir already exists.  Skipping...";
+       else
+               su - opensrf -c "mkdir -p $dir";
+       fi
+done
+
+# copy blsw.json into place for manual editing
+# TODO: automate this part too
+su - $GIT_USER -c "cp $GIT_HOME/backstage/sample.json $PREFS_DIR/bslw.json"
+echo "As the user $GIT_USER, please configure $PREFS_DIR/blsw.json".
+
+# copy lib files into place
+su - $GIT_USER -c "cp -r $GIT_HOME/backstage/Backstage $LIB_DIR/"
+su - $GIT_USER -c "cp -r $GIT_HOME/JSONPrefs/lib/JSONPrefs.pm $LIB_DIR/"
+
+su - $GIT_USER -c "echo $EG_JSON > $PREFS_DIR/evergreen.json"
+
+for line in $EXPORT_PATH $EXPORT_PERL5LIB; do
+       su - $GIT_USER -C "echo $line >> ~/.bashrc"
+done;
+echo "As the $GIT_USER user, please 'source ~/.bashrc' after this script is completed."