Skip to content

Instantly share code, notes, and snippets.

@edgarcosta
Created July 28, 2024 16:32
Show Gist options
  • Save edgarcosta/64740a2350b9525af13a4f4ae8024bab to your computer and use it in GitHub Desktop.
Save edgarcosta/64740a2350b9525af13a4f4ae8024bab to your computer and use it in GitHub Desktop.
major=2
main=28
patch=$1
main() {
set -e
version="${major}.${main}-${patch}"
source_dir="www/magma/${version}/linux"
db_dir="www/magma/databases"
db_files="Atlas.tar.gz data3to8.tar.gz RepRat.tar.gz Trn32IdData.tar.gz TrnGps32.tar.gz"
tmp_dir=$(mktemp -d)
install_dir="/opt/magma/magma-${version}"
download_source="edgarc@laurent.mit.edu"
jump_option=""
hostname=$(hostname)
install_databases=0 # true
[[ $hostname =~ ^(prodweb1|prodweb2|instance) ]] && install_databases=1
[[ $hostname =~ ^(prodweb1|prodweb2|instance) ]] && jump_option="-J edgarcosta@lovelace.mit.edu"
echo "(${hostname}) Installing ${version} at ${install_dir}"
# [[ -d ${install_dir} ]] && echo "${install_dir} already exists, not installing." && return 0
ext="avx2"
[[ $hostname == LEGENDRE ]] && ext="intel64"
[[ $hostname =~ ^(diophantus|kovalevsky) ]] && ext="avx64"
executable="magma.${ext}.exe"
echo "(${hostname}) Copying magma files to ${tmp_dir}..."
files=""
for file in "shared_complete.tar.gz" "${executable}.gz"; do
for ext in "" ".md5"; do
files+=",${source_dir}/${file}${ext}"
done
done
if [ $install_databases -eq 0 ]; then
echo "(${hostname}) Copying database files to ${tmp_dir}..."
for file in $db_files; do
for ext in "" ".md5"; do
files+=",${db_dir}/${file}${ext}"
done
done
fi
echo \{${files:1}\}
echo scp -o StrictHostKeyChecking=accept-new ${jump_option} ${download_source}:\{${files:1}\} ${tmp_dir}
scp -o StrictHostKeyChecking=accept-new ${jump_option} ${download_source}:\{${files:1}\} ${tmp_dir}
echo "done"
cd ${tmp_dir}
md5sum -c *.md5
echo -n "(${hostname}) Extracting magma files..."
tar xf shared_complete.tar.gz
rm shared_complete.tar.gz
sed -i 's/ROOT="....."/ROOT="$(dirname "$(readlink -f "$0")")"/g' magma
cp /opt/magma/current/magmapassfile .
gunzip "${executable}.gz"
mv ${executable} magma.exe
chmod +x magma.exe
echo "done"
if [ $install_databases -eq 0 ]; then
echo -n "(${hostname}) Extracting database files..."
for file in ${db_files}; do
tar -C "libs/data" -xf ${file}
rm ${file}
done
echo "done"
fi
echo -n "(${hostname}) Moving files to ${install_dir}..."
sudo mv ${tmp_dir} ${install_dir}
sudo chmod -R u+rwX,go+rX,go-w ${install_dir}
sudo rm -rf /opt/magma/current
sudo ln -s ${install_dir} /opt/magma/current
echo "done"
echo | magma
echo "Done :)"
set +e
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment