Skip to content

Commit 733d42f

Browse files
Add root_user and root_home variables (#59)
Replace hardwired usernames and home directories with two variables which allow the script run on both old and new platforms.
1 parent 678f873 commit 733d42f

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

kgo_updates/meto_update_kgo.sh

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# *****************************COPYRIGHT*******************************
77

88
# This script will ask for kgo update information then moves the directory kgo_update
9-
# to ~frum. It then calls `run_kgo_script.sh` as frum which itself calls the update
9+
# to ~${root_user}. It then calls `run_kgo_script.sh` as ${root_user} which itself calls the update
1010
# script. It then moves the generated variables files back into the working copy.
1111
# The kgo_update.py script can be run with the --new-release option by providing
1212
# 'new-release' as a command line option to this script
@@ -21,14 +21,18 @@ script_loc="$(dirname "$0")"
2121

2222
# Work out if we're running from azspice or old spice
2323
if [[ $HOSTNAME == "caz"* ]]; then
24+
root_user="umadmin"
25+
root_home="/home/users/umadmin"
2426
launch_platform=azspice
2527
# Check you can sudo in as umadmin
26-
sudo -iu umadmin bash -c "echo ''"
28+
sudo -iu ${root_user} bash -c "echo ''"
2729
if [[ $? -ne 0 ]]; then
2830
printf "${RED} You were unable to run commands as umadmin - this is required to run this script"
2931
printf "This may be because of a password typo or similar"
3032
fi
3133
else
34+
root_user="frum"
35+
root_home="/home/h01/frum"
3236
launch_platform=spice
3337
fi
3438

@@ -125,9 +129,9 @@ fi
125129

126130
# Move the kgo_update directory to frum on linux
127131
if [[ $launch_platform == "spice" ]]; then
128-
scp -rq $script_loc/kgo_update frum@localhost:~
132+
scp -rq $script_loc/kgo_update ${root_user}@localhost:~
129133
else
130-
sudo -iu umadmin bash -c "cp -r $script_loc/kgo_update /home/users/umadmin"
134+
sudo -iu ${root_user} bash -c "cp -r $script_loc/kgo_update ${root_home}"
131135
fi
132136

133137
# Define command to run as frum
@@ -142,11 +146,11 @@ command=". /etc/profile ; module load scitools ; cd kgo_update ;
142146
-V ${version_number} ;
143147
cd ~ ; rm -rf kgo_update"
144148

145-
# Run the command as frum
149+
Run the command as frum
146150
if [[ $launch_platform == "spice" ]]; then
147-
ssh -Y frum@localhost $command
151+
ssh -Y ${root_user}@localhost $command
148152
else
149-
sudo -iu umadmin bash -c "cd $UMDIR ; $command"
153+
sudo -iu ${root_user} bash -c "cd $UMDIR ; $command"
150154
fi
151155

152156
# Error Checking and rsyncing
@@ -157,12 +161,12 @@ succeeded_xc40=0
157161
succeeded_ex1a=0
158162
succeeded_all=1
159163
if [[ $platforms == *"spice"* ]] && [[ $platforms != *"azspice"* ]]; then
160-
file=~frum/${variables_dir}/spice_update_script.sh
164+
file=${root_home}/${variables_dir}/spice_update_script.sh
161165
if [[ -e "$file" ]]; then
162166
succeeded_spice=1
163167
if [[ $new_release -ne 1 ]]; then
164168
printf "${GREEN}\n\nCopying the spice variables file into this working copy.\n${NC}"
165-
scp -q frum@localhost:~/${variables_dir}/spice_updated_variables${variables_extension} \
169+
scp -q ${root_user}@localhost:~/${variables_dir}/spice_updated_variables${variables_extension} \
166170
${wc_path}/rose-stem/site/meto/variables_spice${variables_extension}
167171
if [[ $? -ne 0 ]]; then
168172
printf "${RED}The copy of the spice variables file into this working copy has failed.\n${NC}"
@@ -175,12 +179,12 @@ if [[ $platforms == *"spice"* ]] && [[ $platforms != *"azspice"* ]]; then
175179
fi
176180
fi
177181
if [[ $platforms == *"azspice"* ]]; then
178-
file=~umadmin/${variables_dir}/azspice_update_script.sh
182+
file=${root_home}/${variables_dir}/azspice_update_script.sh
179183
if [[ -e "$file" ]]; then
180184
succeeded_azspice=1
181185
if [[ $new_release -ne 1 ]]; then
182186
printf "${GREEN}\n\nCopying the azspice variables file into this working copy.\n${NC}"
183-
cp /home/users/umadmin/${variables_dir}/azspice_updated_variables${variables_extension} \
187+
cp ${root_home}/${variables_dir}/azspice_updated_variables${variables_extension} \
184188
${wc_path}/rose-stem/site/meto/variables_azspice${variables_extension}
185189
if [[ $? -ne 0 ]]; then
186190
printf "${RED}The copy of the azspice variables file into this working copy has failed.\n${NC}"
@@ -189,20 +193,21 @@ if [[ $platforms == *"azspice"* ]]; then
189193
fi
190194
fi
191195
else
196+
echo $file
192197
succeeded_all=0
193198
fi
194199
fi
195200
if [[ $platforms == *"xc40"* ]]; then
196-
file=~frum/${variables_dir}/xc40_update_script.sh
201+
file=${root_home}/${variables_dir}/xc40_update_script.sh
197202
if [[ -e "$file" ]]; then
198203
succeeded_xc40=1
199204
if [[ $new_release -ne 1 ]]; then
200205
printf "${GREEN}\n\nCopying the xc40 variables file into this working copy.\n${NC}"
201206
if [[ $launch_platform == "spice" ]]; then
202-
scp -q frum@localhost:~/${variables_dir}/xc40_updated_variables${variables_extension} \
207+
scp -q ${root_user}@localhost:~/${variables_dir}/xc40_updated_variables${variables_extension} \
203208
${wc_path}/rose-stem/site/meto/variables_xc40${variables_extension}
204209
else
205-
cp /home/users/umadmin/${variables_dir}/xc40_updated_variables${variables_extension} \
210+
cp ${root_home}/${variables_dir}/xc40_updated_variables${variables_extension} \
206211
${wc_path}/rose-stem/site/meto/variables_xc40${variables_extension}
207212
fi
208213
if [[ $? -ne 0 ]]; then
@@ -216,16 +221,16 @@ if [[ $platforms == *"xc40"* ]]; then
216221
fi
217222
fi
218223
if [[ $platforms == *"ex1a"* ]]; then
219-
file=~frum/${variables_dir}/ex1a_update_script.sh
224+
file=${root_home}/${variables_dir}/ex1a_update_script.sh
220225
if [[ -e "$file" ]]; then
221226
succeeded_ex1a=1
222227
if [[ $new_release -ne 1 ]]; then
223228
printf "${GREEN}\n\nCopying the ex1a variables file into this working copy.\n${NC}"
224229
if [[ $launch_platform == "spice" ]]; then
225-
scp -q frum@localhost:~/${variables_dir}/ex1a_updated_variables${variables_extension} \
230+
scp -q ${root_user}@localhost:~/${variables_dir}/ex1a_updated_variables${variables_extension} \
226231
${wc_path}/rose-stem/site/meto/variables_ex1a${variables_extension}
227232
else
228-
cp /home/users/umadmin/${variables_dir}/ex1a_updated_variables${variables_extension} \
233+
cp ${root_home}/${variables_dir}/ex1a_updated_variables${variables_extension} \
229234
${wc_path}/rose-stem/site/meto/variables_ex1a${variables_extension}
230235
fi
231236
if [[ $? -ne 0 ]]; then
@@ -260,9 +265,9 @@ if [[ $succeeded_xc40 -eq 1 ]]; then
260265
host_rsync=$(rose host-select xc)
261266
rsync_com="ssh -Y ${host_rsync} 'rsync -av /projects/um1/standard_jobs/${rsync_dir} xcslr0:/common/um1/standard_jobs/${rsync_dir}'"
262267
if [[ $launch_platform == "spice" ]]; then
263-
ssh -Y frum@localhost $rsync_com
268+
ssh -Y ${root_user}@localhost $rsync_com
264269
else
265-
sudo -iu umadmin bash -c '$rsync_com'
270+
sudo -iu ${root_user} bash -c '$rsync_com'
266271
fi
267272
if [[ $? -ne 0 ]]; then
268273
printf "${RED}The rsync to the xcs has failed.\n${NC}"
@@ -285,9 +290,9 @@ if [[ $succeeded_ex1a -eq 1 ]]; then
285290
# rsync to EXZ
286291
rsync_com="ssh -Y ${host_rsync} 'rsync -av /common/internal/umdir/standard_jobs/${rsync_dir} login.exz:/common/umdir/standard_jobs/${rsync_dir}'"
287292
if [[ $launch_platform == "spice" ]]; then
288-
ssh -Y frum@localhost $rsync_com
293+
ssh -Y ${root_user}@localhost $rsync_com
289294
else
290-
sudo -iu umadmin bash -c '$rsync_com'
295+
sudo -iu ${root_user} bash -c '$rsync_com'
291296
fi
292297
if [[ $? -ne 0 ]]; then
293298
printf "${RED}The rsync to the exz has failed.\n${NC}"
@@ -299,17 +304,17 @@ if [[ $succeeded_ex1a -eq 1 ]]; then
299304
excd_host=$(rose host-select excd)
300305
rsync_com="ssh -Y ${host_rsync} 'rsync -av /common/internal/umdir/standard_jobs/${rsync_dir} ${excd_host}:/common/internal/umdir/standard_jobs/${rsync_dir}'"
301306
if [[ $launch_platform == "spice" ]]; then
302-
ssh -Y frum@localhost $rsync_com
307+
ssh -Y ${root_user}@localhost $rsync_com
303308
else
304-
sudo -iu umadmin bash -c '$rsync_com'
309+
sudo -iu ${root_user} bash -c '$rsync_com'
305310
fi
306311
if [[ $? -ne 0 ]]; then
307312
printf "${RED}The rsync to the excd has failed.\n${NC}"
308313
else
309314
printf "${Green}The rsync to the excd has succeeded.\n${NC}"
310315
fi
311316
elif [[ $platforms == *"ex1a"* ]]; then
312-
printf "${RED}\n\nSkipping the rsync to the exa as the exz install failed.\n${NC}"
317+
printf "${RED}\n\nSkipping the rsync to the exz/cd as the exab install failed.\n${NC}"
313318
fi
314319

315320
printf "\n\nInstallation Summary:\n\n"

0 commit comments

Comments
 (0)