-
-
Save demaisj/def1d98fe5ca5023b5ded32e62afe6d4 to your computer and use it in GitHub Desktop.
Install script for a private repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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