updating user, variable-izing some things
authorChris Sharp <csharp@georgialibraries.org>
Tue, 7 Feb 2017 13:03:59 +0000 (08:03 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Tue, 7 Feb 2017 13:03:59 +0000 (08:03 -0500)
update-sip.sh

index c663828..84ea595 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Copyright (C) 2012 Georgia Public Library Service
+# Copyright (C) 2012-2017 Georgia Public Library Service
 # Chris Sharp <csharp@georgialibraries.org>
 #    
 #    This program is free software: you can redistribute it and/or modify
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-# This is a script to easily access the /openils/conf/oils_sip.xml file,
+# This is a script to easily access the $SIP_CONFIG file,
 # add an account, and copy it over to sip02. For this to work smoothly, 
 # you will want to set up an ssh key between this server and the "OTHER_SIP"
 # servers.
 
-EDITOR=vim
-OTHER_SIP='sip02' # list hostnames (as defined in /etc/hosts) to which the altered file needs to be copied (i.e., your other SIP servers)
+EDITOR="vim"
+USER="opensrf"
+SIP_CONFIG="/openils/conf/oils_sip.xml"
+OTHER_SIP="sip02" # list hostnames (as defined in /etc/hosts) to which the altered file needs to be copied (i.e., your other SIP servers)
 
 echo "Creating backup of SIP configuration"
-cp -v /openils/conf/oils_sip.xml /openils/conf/oils_sip.xml.`date +%F`
-su - opensrf -c "$EDITOR /openils/conf/oils_sip.xml"
+cp -v $SIP_CONFIG $SIP_CONFIG.`date +%F`
+$EDITOR $SIP_CONFIG
 for server in $OTHER_SIP;
        do 
                # back up the existing conf file
                echo "Creating backup of configuration on $server"
-               ssh root@$server cp -v /openils/conf/oils_sip.xml /openils/conf/oils_sip.xml.`date +%F`
+               ssh $USER@$server cp -v $SIP_CONFIG $SIP_CONFIG.`date +%F`
                echo "Copying new configuration to $server"
-               scp /openils/conf/oils_sip.xml root@$server:/openils/conf/oils_sip.xml
-               echo "Restoring file ownership to opensrf on $server"
-               ssh root@$server "chown -v opensrf:opensrf /openils/conf/oils_sip.*"
+               scp $SIP_CONFIG $USER@$server:$SIP_CONFIG
                echo "Done with $server";
 done