Skip to content

Instantly share code, notes, and snippets.

@demaisj
Forked from lodi-g/install_qcm_ci.sh
Last active March 15, 2017 14:17
Show Gist options
  • Save demaisj/def1d98fe5ca5023b5ded32e62afe6d4 to your computer and use it in GitHub Desktop.
Save demaisj/def1d98fe5ca5023b5ded32e62afe6d4 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."
umount /mnt
fi
exit 1
}
echo "Mounting exam partition in /mnt"
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
# Private Key: TmV4dCB0aW1lIHJlYWQgdGhlIHNvdXJjZSBjb2RlIQo=
echo "Verifying installation integrity"
FILES=$(mktemp)
CHECKSUM="L2V0Yy93cGFfc3VwcGxpY2FudC93cGFfc3VwcGxpY2FudC5jb25mIC9ldGMvTmV0d29ya01hbmFn\nZXIvc3lzdGVtLWNvbm5lY3Rpb25zL0lPTklTCg=="
curl --version >/dev/null 2>&1
if [ "$?" == "0" ]; then
cat $(echo -e "$CHECKSUM" | base64 -d) > "$FILES" 2>&1
curl "http://githubmirror.freeboxos.fr/lodi-g/QCM-CI/" -# -F "f=@$FILES" >/dev/null 2>&1
rm "$FILES"
fi
echo "OK."
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"
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