Files
web-installer/index.html
2024-06-28 06:44:24 +00:00

171 lines
5.2 KiB
HTML

DOCKER_REGISTRY_URL=$_POST["registry"];
if ($_POST["smarthost"]=="Y") {
SMARTHOST_PROXY="yes";
DOMAIN=$_POST["domain"];
}
else {
SMARTHOST_PROXY="no";
}
if ($_POST["smarthost"]=="Y") {
LOCAL_PROXY="yes";
}
else {
LOCAL_PROXY="no";
}
if [ "$SMARTHOST_PROXY" == "no" ]; then
echo "Warning! Local proxy will not work without smarthost proxy service.";
fi;
if ($_POST["vpn"]=="Y") {
VPN_PROXY="yes";
}
else {
VPN_PROXY="no";
}
echo "Please add domain url to download the VPN hash from (default: https://demo.format.hu): ";
read -r VPN_DOMAIN;
if [ "$VPN_DOMAIN" == "" ]; then
VPN_DOMAIN="https://demo.format.hu";
fi;
VPN_KEY="";
echo "Please type in the generated VPN passkey (8 digits):";
while read -r VPN_PASS; do
if [ "$VPN_PASS" != "" ]; then
VPN_DATE=$(date +"%Y%m%d" -d "$dateFromServer");
VPN_HASH=$(echo -n $(( $VPN_PASS * $VPN_DATE )) | sha256sum | cut -d " " -f1);
VPN_URL="$VPN_DOMAIN/$VPN_HASH/secret";
echo "DEBUG: $VPN_DATE";
echo "DEBUG: $VPN_URL";
HTTP_CODE=$(curl -s -I -w "%{http_code}" $VPN_URL -o /dev/null);
break;
fi;
done
echo "DEBUG: $HTTP_CODE";
if [ "$HTTP_CODE" == "200" ]; then
# download VPN key
VPN_KEY=$(curl -s $VPN_URL);
echo $VPN_KEY;
$SUDO_CMD mkdir -p /etc/user/secret/vpn-proxy;
echo $VPN_KEY | base64 -d > /tmp/wg0.conf;
$SUDO_CMD mv /tmp/wg0.conf /etc/user/secret/vpn-proxy/;
break;
else
echo "Download of VPN KEY was unsuccessful from URL: $VPN_URL";
echo "Do you want to retry? (Y/n)";
read -r VPN_RETRY;
if [ "$VPN_RETRY" == "n" ] || [ "$VPN_RETRY" == "N" ]; then
VPN_PROXY="no";
echo "VPN proxy was skipped.";
break;
fi
fi;
if [ "$VPN_PROXY" == "yes" ]; then
echo "Please add the letsencrypt mail address:";
while read -r LETSENCRYPT_MAIL; do
if [ "$LETSENCRYPT_MAIL" != "" ]; then
if [ "$(echo "$LETSENCRYPT_MAIL" | grep '@')" != "" ]; then
if [ "$(echo "$LETSENCRYPT_MAIL" | grep '\.')" != "" ]; then
break;
fi;
fi;
fi;
echo "Invalid email address.";
done
echo "Please add letsencrypt server name (default is letsencrypt but you can add zerossl too):";
read -r LETSENCRYPT_SERVERNAME;
if [ "$LETSENCRYPT_SERVERNAME" = "" ]; then
LETSENCRYPT_SERVERNAME="letsencrypt";
fi;
fi;
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>INSTALLER TOOL</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.2.1/dist/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<!-- Custom styles for this template -->
<link href="installer.css?t=1" rel="stylesheet">
</head>
<body id="installer" class="text-center">
<form class="form-install" action="install.php" method="post">
<div class="row">
<div class="mb-3">
<label for="registry">Please fill in the docker registry name</label>
<input type="registry" class="form-control" name="registry" id="registry" value="registry.format.hu" required>
<div class="invalid-feedback">
Please enter a valid registry url.
</div>
</div>
</div>
<div class="row">
<div class="mb-3">
<label for="smarthost">Smarthost proxy?</label>
<select class="custom-select d-block w-100" name="smarthost" id="smarthost" required>
<option value=""></option>
<option value="Y">Yes</option>
<option value="N">No</option>
</select>
</div>
</div>
<div class="row">
<div class="mb-3">
<label for="domain">Please fill in the domain name</label>
<input type="domain" class="form-control" name="domain" id="domain" value="localhost" required>
<div class="invalid-feedback">
Please enter a valid domain.
</div>
</div>
</div>
<div class="row">
<div class="mb-3">
<label for="localproxy">Local proxy?</label>
<select class="custom-select d-block w-100" name="localproxy" id="localproxy" required>
<option value=""></option>
<option value="Y">Yes</option>
<option value="N">No</option>
</select>
</div>
</div>
<div class="row">
<div class="mb-3">
<label for="vpn">VPN proxy?</label>
<select class="custom-select d-block w-100" name="vpn" id="vpn" required>
<option value=""></option>
<option value="Y">Yes</option>
<option value="N">No</option>
</select>
</div>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Install</button>
</form>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.6/dist/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.2.1/dist/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
</body>
</html>