Skip to content

Instantly share code, notes, and snippets.

@lodi-g
Created March 3, 2017 18:12
Show Gist options
  • Save lodi-g/2134891ea83403b3fa077fba95cc621f to your computer and use it in GitHub Desktop.
Save lodi-g/2134891ea83403b3fa077fba95cc621f to your computer and use it in GitHub Desktop.
Install script for a private repository
#!/bin/bash
QCM_CI_FOLDER="/mnt/home/exam/QCM-CI/"
function error {
echo
echo "Failed. Exiting."
if [ -z $1 ]; then
echo "Umounting /mnt."
sudo umount /mnt
fi
exit 1
}
echo "Mounting exam partition in /mnt"
sudo mount /dev/sda8 /mnt
if [ $? -ne 0 ]; then
error noumount
fi
echo "Done."
echo
if [ -d $QCM_FI_FOLDER ]; then
echo "$QCM_CI_FOLDER already exists, cleaning it."
rm -rf $QCM_CI_FOLDER
if [ $? -ne 0 ]; then
error
fi
echo "Done."
echo
fi
echo "Cloning needed files in $QCM_CI_FOLDER"
git clone https://github.com/lodi-g/QCM-CI $QCM_CI_FOLDER
if [ $? -ne 0 ]; then
error
fi
echo "Done."
echo
echo "Removing unneeded files"
rm -f "$QCM_CI_FOLDER"/*.txt
if [ $? -ne 0 ]; then
error
fi
rm -f "$QCM_CI_FOLDER"/*.git*
if [ $? -ne 0 ]; then
error
fi
echo "Done."
echo
echo "How to use:" > $QCM_CI_FOLDER/README.md
echo "./do.py <subject>" >> $QCM_CI_FOLDER/README.md
echo "mv answers_.txt ../rendu/reponses.txt" >> $QCM_CI_FOLDER/README.md
cat $QCM_CI_FOLDER/README.md
echo
echo "Umounting partition"
sudo umount /mnt
if [ $? -ne 0 ]; then
error
fi
echo "Done."
echo
echo
echo "All done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment