Skip to content

add root_user variable #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions kgo_updates/meto_update_kgo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# *****************************COPYRIGHT*******************************

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

# Work out if we're running from azspice or old spice
if [[ $HOSTNAME == "caz"* ]]; then
root_user="umadmin"
root_home="/home/users/umadmin"
launch_platform=azspice
# Check you can sudo in as umadmin
sudo -iu umadmin bash -c "echo ''"
sudo -iu ${root_user} bash -c "echo ''"
if [[ $? -ne 0 ]]; then
printf "${RED} You were unable to run commands as umadmin - this is required to run this script"
printf "This may be because of a password typo or similar"
fi
else
root_user="frum"
root_home="/home/h01/frum"
launch_platform=spice
fi

Expand Down Expand Up @@ -125,9 +129,9 @@ fi

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

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

# Run the command as frum
Run the command as frum
if [[ $launch_platform == "spice" ]]; then
ssh -Y frum@localhost $command
ssh -Y ${root_user}@localhost $command
else
sudo -iu umadmin bash -c "cd $UMDIR ; $command"
sudo -iu ${root_user} bash -c "cd $UMDIR ; $command"
fi

# Error Checking and rsyncing
Expand All @@ -157,12 +161,12 @@ succeeded_xc40=0
succeeded_ex1a=0
succeeded_all=1
if [[ $platforms == *"spice"* ]] && [[ $platforms != *"azspice"* ]]; then
file=~frum/${variables_dir}/spice_update_script.sh
file=${root_home}/${variables_dir}/spice_update_script.sh
if [[ -e "$file" ]]; then
succeeded_spice=1
if [[ $new_release -ne 1 ]]; then
printf "${GREEN}\n\nCopying the spice variables file into this working copy.\n${NC}"
scp -q frum@localhost:~/${variables_dir}/spice_updated_variables${variables_extension} \
scp -q ${root_user}@localhost:~/${variables_dir}/spice_updated_variables${variables_extension} \
${wc_path}/rose-stem/site/meto/variables_spice${variables_extension}
if [[ $? -ne 0 ]]; then
printf "${RED}The copy of the spice variables file into this working copy has failed.\n${NC}"
Expand All @@ -175,12 +179,12 @@ if [[ $platforms == *"spice"* ]] && [[ $platforms != *"azspice"* ]]; then
fi
fi
if [[ $platforms == *"azspice"* ]]; then
file=~umadmin/${variables_dir}/azspice_update_script.sh
file=${root_home}/${variables_dir}/azspice_update_script.sh
if [[ -e "$file" ]]; then
succeeded_azspice=1
if [[ $new_release -ne 1 ]]; then
printf "${GREEN}\n\nCopying the azspice variables file into this working copy.\n${NC}"
cp /home/users/umadmin/${variables_dir}/azspice_updated_variables${variables_extension} \
cp ${root_home}/${variables_dir}/azspice_updated_variables${variables_extension} \
${wc_path}/rose-stem/site/meto/variables_azspice${variables_extension}
if [[ $? -ne 0 ]]; then
printf "${RED}The copy of the azspice variables file into this working copy has failed.\n${NC}"
Expand All @@ -189,20 +193,21 @@ if [[ $platforms == *"azspice"* ]]; then
fi
fi
else
echo $file
succeeded_all=0
fi
fi
if [[ $platforms == *"xc40"* ]]; then
file=~frum/${variables_dir}/xc40_update_script.sh
file=${root_home}/${variables_dir}/xc40_update_script.sh
if [[ -e "$file" ]]; then
succeeded_xc40=1
if [[ $new_release -ne 1 ]]; then
printf "${GREEN}\n\nCopying the xc40 variables file into this working copy.\n${NC}"
if [[ $launch_platform == "spice" ]]; then
scp -q frum@localhost:~/${variables_dir}/xc40_updated_variables${variables_extension} \
scp -q ${root_user}@localhost:~/${variables_dir}/xc40_updated_variables${variables_extension} \
${wc_path}/rose-stem/site/meto/variables_xc40${variables_extension}
else
cp /home/users/umadmin/${variables_dir}/xc40_updated_variables${variables_extension} \
cp ${root_home}/${variables_dir}/xc40_updated_variables${variables_extension} \
${wc_path}/rose-stem/site/meto/variables_xc40${variables_extension}
fi
if [[ $? -ne 0 ]]; then
Expand All @@ -216,16 +221,16 @@ if [[ $platforms == *"xc40"* ]]; then
fi
fi
if [[ $platforms == *"ex1a"* ]]; then
file=~frum/${variables_dir}/ex1a_update_script.sh
file=${root_home}/${variables_dir}/ex1a_update_script.sh
if [[ -e "$file" ]]; then
succeeded_ex1a=1
if [[ $new_release -ne 1 ]]; then
printf "${GREEN}\n\nCopying the ex1a variables file into this working copy.\n${NC}"
if [[ $launch_platform == "spice" ]]; then
scp -q frum@localhost:~/${variables_dir}/ex1a_updated_variables${variables_extension} \
scp -q ${root_user}@localhost:~/${variables_dir}/ex1a_updated_variables${variables_extension} \
${wc_path}/rose-stem/site/meto/variables_ex1a${variables_extension}
else
cp /home/users/umadmin/${variables_dir}/ex1a_updated_variables${variables_extension} \
cp ${root_home}/${variables_dir}/ex1a_updated_variables${variables_extension} \
${wc_path}/rose-stem/site/meto/variables_ex1a${variables_extension}
fi
if [[ $? -ne 0 ]]; then
Expand Down Expand Up @@ -260,9 +265,9 @@ if [[ $succeeded_xc40 -eq 1 ]]; then
host_rsync=$(rose host-select xc)
rsync_com="ssh -Y ${host_rsync} 'rsync -av /projects/um1/standard_jobs/${rsync_dir} xcslr0:/common/um1/standard_jobs/${rsync_dir}'"
if [[ $launch_platform == "spice" ]]; then
ssh -Y frum@localhost $rsync_com
ssh -Y ${root_user}@localhost $rsync_com
else
sudo -iu umadmin bash -c '$rsync_com'
sudo -iu ${root_user} bash -c '$rsync_com'
fi
if [[ $? -ne 0 ]]; then
printf "${RED}The rsync to the xcs has failed.\n${NC}"
Expand All @@ -285,9 +290,9 @@ if [[ $succeeded_ex1a -eq 1 ]]; then
# rsync to EXZ
rsync_com="ssh -Y ${host_rsync} 'rsync -av /common/internal/umdir/standard_jobs/${rsync_dir} login.exz:/common/umdir/standard_jobs/${rsync_dir}'"
if [[ $launch_platform == "spice" ]]; then
ssh -Y frum@localhost $rsync_com
ssh -Y ${root_user}@localhost $rsync_com
else
sudo -iu umadmin bash -c '$rsync_com'
sudo -iu ${root_user} bash -c '$rsync_com'
fi
if [[ $? -ne 0 ]]; then
printf "${RED}The rsync to the exz has failed.\n${NC}"
Expand All @@ -299,17 +304,17 @@ if [[ $succeeded_ex1a -eq 1 ]]; then
excd_host=$(rose host-select excd)
rsync_com="ssh -Y ${host_rsync} 'rsync -av /common/internal/umdir/standard_jobs/${rsync_dir} ${excd_host}:/common/internal/umdir/standard_jobs/${rsync_dir}'"
if [[ $launch_platform == "spice" ]]; then
ssh -Y frum@localhost $rsync_com
ssh -Y ${root_user}@localhost $rsync_com
else
sudo -iu umadmin bash -c '$rsync_com'
sudo -iu ${root_user} bash -c '$rsync_com'
fi
if [[ $? -ne 0 ]]; then
printf "${RED}The rsync to the excd has failed.\n${NC}"
else
printf "${Green}The rsync to the excd has succeeded.\n${NC}"
fi
elif [[ $platforms == *"ex1a"* ]]; then
printf "${RED}\n\nSkipping the rsync to the exa as the exz install failed.\n${NC}"
printf "${RED}\n\nSkipping the rsync to the exz/cd as the exab install failed.\n${NC}"
fi

printf "\n\nInstallation Summary:\n\n"
Expand Down