downloads/sbmigrate-site
... ...
@@ -3,12 +3,13 @@
3 3
4 4
USAGE="Usage : sbmigrate-site [ site name ]"
5 5
6
-
7 6
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
8 7
INSTALLERCONFIG="$HOME/.sbgrid_installer"
9 8
BACKUPCONFIG="$HOME/.sbgrid_installer_site_migrated"
10 9
SITENAME_FILE="/programs/share/sitename"
11 10
11
+echo "Running pre-migration checks"
12
+
12 13
touch "/programs/share/site_migrate_check" 2>/dev/null
13 14
if [ $? != 0 ]; then
14 15
echo "This user cannot write to /programs/share"
... ...
@@ -17,7 +18,7 @@ if [ $? != 0 ]; then
17 18
echo "continue without write access. "
18 19
exit 1
19 20
else
20
- echo "Write check passed."
21
+ echo " - Write check passed."
21 22
fi
22 23
23 24
if [ ! -e $INSTALLERCONFIG ]; then
... ...
@@ -25,13 +26,13 @@ if [ ! -e $INSTALLERCONFIG ]; then
25 26
echo "Cannot continue migration. Exiting."
26 27
exit 1
27 28
else
28
- echo "$INSTALLERCONFIG config found."
29
+ echo " - $INSTALLERCONFIG config found."
29 30
fi
30 31
31 32
if [ -f $SITENAME_FILE ]; then
32 33
SITENAME=$(cat $SITENAME_FILE)
33 34
DATABASE="/programs/share/packages-${SITENAME}.db"
34
- echo "sitename file found."
35
+ echo " - sitename file found."
35 36
else
36 37
echo "No site configuration found."
37 38
echo "Cannot continue migration. Exiting."
... ...
@@ -43,39 +44,77 @@ if [ ! -e "${DATABASE}" ]; then
43 44
echo "Cannot continue migration. Exiting."
44 45
exit 1
45 46
else
46
- echo "database file found at: $DATABASE"
47
+ echo " - database file found at: $DATABASE"
47 48
fi
48 49
49
-echo "Required installation files found."
50
+echo "All required installation files found."
50 51
echo "---------------------------------"
51 52
echo
52 53
53 54
if [ $1 ]; then
54 55
install_sitename=$1
55 56
else
56
- echo "This script will migration your the site configuration"
57
+ echo "This script will migrate the site configuration"
57 58
echo "for your SBGrid installation. You will be able to"
58
- echo "confirm your settings before the migration happens. You"
59
- echo "will need the new site name that was sent ny email."
60
- echo "This process should be fast and will not impact running jobs."
59
+ echo "confirm your settings before the migration happens."
60
+ echo "You may need the new site name that was sent by email"
61
+ echo "if your advisor is not listed below."
62
+ echo "The process will be fast and will not impact running jobs."
61 63
echo
62 64
echo "Exit at any time with a CTRL-c."
63 65
echo
66
+
64 67
unset install_sitename
65
- echo "Enter the SBGrid site name:"
66
- read install_sitename
68
+ echo "Please select your site name from this list:"
69
+ echo " PI (site name)"
70
+ echo "1) Dessen (dessen_a_514i)"
71
+ echo "2) Nicolet (nicolet_y_359i)"
72
+ echo "3) Nury (nury_h_512i)"
73
+ echo "4) Petosa (petosa_c_148i)"
74
+ echo "5) Schoehn (schoehn_g_408i)"
75
+ echo "6) Weik (weik_m_513i)"
76
+ echo "7) Other (enter manually)"
77
+ echo "---------------------------------"
78
+ read labvar
79
+
80
+ case $labvar in
81
+ 1)
82
+ install_sitename="dessen_a_514i"
83
+ ;;
84
+ 2)
85
+ install_sitename="nicolet_y_359i"
86
+ ;;
87
+ 3)
88
+ install_sitename="nury_h_512i"
89
+ ;;
90
+ 4)
91
+ install_sitename="petosa_c_148i"
92
+ ;;
93
+ 5)
94
+ install_sitename="schoehn_g_408i"
95
+ ;;
96
+ 6)
97
+ install_sitename="weik_m_513i"
98
+ ;;
99
+ *)
100
+ echo "Enter the SBGrid site name:"
101
+ read install_sitename
102
+ ;;
103
+ esac
67 104
fi
68 105
69 106
echo "Does this site name look correct? Y/n"
70
-echo
71
-echo $install_sitename
72
-echo
107
+echo " "
108
+echo " $install_sitename"
109
+echo " "
73 110
74 111
read confirmation
75
-if [ $confirmation == Y ]; then
76
- echo "Great. Migrating installation."
112
+if [ $confirmation == Y ] || [ $confirmation == y ] ; then
113
+ echo "Great. Migrating this installation."
114
+ echo " "
77 115
else
78
- echo "No problem, we can start over. No files were changed."
116
+ echo "No problem, we can start over."
117
+ echo "No files were changed."
79 118
exit 0
80 119
fi
81 120
... ...
@@ -87,18 +126,16 @@ fi
87 126
88 127
# create new .sbgrid_installer file
89 128
TMPCONFIG="${INSTALLERCONFIG}.tmp"
90
-if [ -e $TMPCONFIG ]; then
91
- rm $TMPCONFIG
92
-fi
93 129
94 130
if [ ! -e $BACKUPCONFIG ]; then
95 131
cp -av $INSTALLERCONFIG $BACKUPCONFIG
96 132
else
97
- echo "backup config found from previous migration"
133
+ echo "Backup config found from previous migration"
98 134
echo "Will not overwrite $BACKUPCONFIG"
99 135
fi
100 136
101
-cp -av $INSTALLERCONFIG $TMPCONFIG
137
+# do
138
+cat $INSTALLERCONFIG > $TMPCONFIG
102 139
103 140
head -n 1 $TMPCONFIG >${INSTALLERCONFIG}
104 141
echo "site = $install_sitename" >>${INSTALLERCONFIG}
... ...
@@ -106,6 +143,7 @@ grep 'user = ' $TMPCONFIG >>${INSTALLERCONFIG}
106 143
grep 'key = ' $TMPCONFIG >>${INSTALLERCONFIG}
107 144
grep 'target = ' $TMPCONFIG >>${INSTALLERCONFIG}
108 145
echo >>${INSTALLERCONFIG}
146
+echo "Configuration update completed."
109 147
110 148
echo "$install_sitename" >${SITENAME_FILE}
111 149
NEWDATABASE="/programs/share/packages-${install_sitename}.db"
... ...
@@ -113,18 +151,18 @@ NEWDATABASE="/programs/share/packages-${install_sitename}.db"
113 151
if [ ! -e "$DATABASE.backup" ]; then
114 152
cp -av $DATABASE $DATABASE.backup
115 153
else
116
- echo "previously backed-up database exists"
154
+ echo "Previously database backed-up exists"
117 155
fi
118 156
119 157
if [ -e $NEWDATABASE ]; then
120 158
echo "previously migrated database exists:"
121 159
echo "$NEWDATABASE"
122
- echo will be overwritten.
160
+ echo "This will be overwritten."
123 161
fi
124 162
125
-mv -f $DATABASE $NEWDATABASE
163
+mv -vf $DATABASE $NEWDATABASE
126 164
if [ $? == 0 ]; then
127
- echo "database move successful"
165
+ echo "Database move successful"
128 166
echo "Migration complete!."
129 167
130 168
else