#!/bin/sh Additional packages required: megatools,	MEGAcmd and git
V=-1 RD=FC/ LD=/tmp/FC U=anon@anon.anon P=13245 Branch=git@ssh.gitgud.io:pregmodfan/fc-pregmod.git ; echo "Fresh clone?" && read VN && clear && mega-login $U $P > /dev/null
while true; do
	if [[ $VN == y||$VN == yes ]]; then V=2 && mkdir $LD ; git clone -q $Branch $LD
	elif [[ $VN == n||$VN == no||$V = 0 ]]; then cd $LD/ && git fetch -q
		if  [ `git rev-list HEAD...origin/pregmod-master --count` != 0 ]; then git pull -q && V=1
		fi #Check is a slight tweak of https://stackoverflow.com/a/17192101
	fi
	if [[ $VN == na||$V == 2||$V == 1 ]]; then V=0 && cd $LD/ && rm bin/*.html ; ./compile > /dev/null && minify -o bin/FC_pregmod.html bin/FC_pregmod.html && mv bin/FC_pregmod.html "bin/FC-pregmod-$(git log -1 --format='%cd' --date='format:%d-%m-%Y-%H-%M')-$(git log -n1 --abbrev-commit|grep -m1 commit|sed 's/commit //')".html && mega-put bin/*.html FC/ && megals -u $U -p $P /Root/FC|sed -n '1!p'|sort -r|tail -n +11|paste -sd " " -|xargs megarm -u $U -p $P > /dev/null
	fi
	clear && sleep 15m
done 