Merge branch 'main' of ssh://git.format.hu/format/web-installer
This commit is contained in:
@@ -73,9 +73,10 @@ COPY nginx.conf /etc/nginx/nginx.conf
|
||||
RUN mkdir -p /usr/share/nginx/html
|
||||
COPY index.html /usr/share/nginx/html
|
||||
COPY manage.html /usr/share/nginx/html
|
||||
COPY scan.php /usr/share/nginx/html
|
||||
COPY functions.php /usr/share/nginx/html
|
||||
COPY install.html /usr/share/nginx/html
|
||||
COPY install.php /usr/share/nginx/html
|
||||
COPY install.sh /usr/share/nginx/html
|
||||
COPY installer.css /usr/share/nginx/html
|
||||
RUN chown -R nginx:nginx /usr/share/nginx/html
|
||||
|
||||
|
122
functions.php
122
functions.php
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$REDIS_HOST='redis';
|
||||
$REDIS_HOST='redis-server';
|
||||
|
||||
function ping_redis() {
|
||||
|
||||
@@ -12,25 +12,28 @@ function ping_redis() {
|
||||
else return false;
|
||||
}
|
||||
|
||||
function check_redis($group="webin") {
|
||||
function check_redis($group="scheduler_in", $key="") {
|
||||
|
||||
global $REDIS_HOST;
|
||||
|
||||
$redis = new Redis();
|
||||
$redis->connect($REDIS_HOST);
|
||||
if ($redis->ping()) {
|
||||
$members = $redis->sMembers($group); // redis-cli -h safebox-redis smembers generated
|
||||
$members = $redis->sMembers($group); // redis-cli -h redis-server smembers $group
|
||||
//print_r($members);
|
||||
|
||||
foreach ($members as $member) {
|
||||
if ($key!="" && $member!=$key) continue; // check a specific key in a group
|
||||
|
||||
$value = $redis->get($member);
|
||||
$json_data = base64_decode($value);
|
||||
$data = json_decode($json_data);
|
||||
$data = json_decode($json_data,true);
|
||||
if ($data === null) {
|
||||
echo "JSON read error...";
|
||||
// TODO json error
|
||||
}
|
||||
else {
|
||||
return array("$member" => $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,12 +46,12 @@ function redis_get($key) {
|
||||
$redis = new Redis();
|
||||
$redis->connect($REDIS_HOST);
|
||||
if ($redis->ping()) {
|
||||
//$arList = $redis->keys("*"); // ? redis-cli -h safebox-redis keys "*"
|
||||
//$arList = $redis->keys("*"); // ? redis-cli -h redis-server keys "*"
|
||||
//echo "Stored keys in redis:";
|
||||
//print_r($arList);
|
||||
if ($redis->exists($key)) {
|
||||
$value = $redis->get($key);
|
||||
//redis-cli -h safebox-redis get $key
|
||||
//redis-cli -h redis-server get $key
|
||||
return base64_decode($value);
|
||||
} else {
|
||||
echo "Key does not exist: $key";
|
||||
@@ -67,10 +70,10 @@ function redis_set($key, $value) {
|
||||
if ($redis->ping()) {
|
||||
if (!$redis->exists($key)) {
|
||||
//redis-cli -h redis set $key "$value"
|
||||
//redis-cli -h redis sadd webout $key
|
||||
//redis-cli -h redis smembers webout
|
||||
//redis-cli -h redis sadd web_in $key
|
||||
//redis-cli -h redis smembers web_in
|
||||
$redis->set($key, base64_encode($value));
|
||||
$redis->sAdd('webout', $key);
|
||||
$redis->sAdd('web_in', $key);
|
||||
} else {
|
||||
echo "Key already exist: $key";
|
||||
}
|
||||
@@ -79,15 +82,112 @@ function redis_set($key, $value) {
|
||||
|
||||
function redis_remove($key) {
|
||||
|
||||
global $REDIS_HOST;
|
||||
|
||||
$redis = new Redis();
|
||||
$redis->connect($REDIS_HOST);
|
||||
// $redis->auth('password');
|
||||
if ($redis->ping()) {
|
||||
//redis-cli -h redis srem webin $key
|
||||
//redis-cli -h redis srem web_out $key
|
||||
//redis-cli -h redis del $key
|
||||
$redis->srem("webin", $key);
|
||||
$redis->srem("web_out", $key);
|
||||
$redis->del($key);
|
||||
}
|
||||
}
|
||||
|
||||
// not in use
|
||||
function put_install_envs() {
|
||||
|
||||
// TEMP
|
||||
putenv('HOME=/home/hael');
|
||||
putenv('USER=hael');
|
||||
|
||||
putenv('DOCKER_REGISTRY_URL='.$_POST["registry"]);
|
||||
|
||||
putenv('SMARTHOST_PROXY='.$_POST["smarthost"]);
|
||||
if ($_POST["smarthost"]=="Y") {
|
||||
if ($_POST["domain"]=="") $_POST["domain"] = "localhost";
|
||||
putenv('DOMAIN='.$_POST["domain"]);
|
||||
# if not FQDN
|
||||
$arr = explode(".",$_POST["DOMAIN"]);
|
||||
if (count($arr)==1) {
|
||||
echo "Warning! It seems DOMAAIN is not an FQDN. Self-signed certificate will be created only.";
|
||||
putenv('SELF_SIGNED_CERTIFICATE=true');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
putenv('LOCAL_PROXY='.$_POST["localproxy"]);
|
||||
putenv('VPN_PROXY='.$_POST["vpn"]);
|
||||
if ($_POST["vpn"]=="yes") {
|
||||
putenv('VPN_DOMAIN='.$_POST["vpn_domain"]);
|
||||
putenv('VPN_KEY='.$_POST["vpn_key"]);
|
||||
|
||||
putenv('LETSENCRYPT_MAIL='.$_POST["letsencrypt_mail"]);
|
||||
putenv('LETSENCRYPT_SERVERNAME='.$_POST["letsencrypt_servername"]);
|
||||
}
|
||||
putenv('CRON='.$_POST["cron"]);
|
||||
putenv('DISCOVERY='.$_POST["discovery"]);
|
||||
|
||||
if ($_POST["discovery"]=="yes") {
|
||||
if ($_POST["DISCOVERY_DIR"] == "" ) $_POST["DISCOVERY_DIR"]="/usr/local/bin/";
|
||||
if (substr($_POST["DISCOVERY_DIR"],0,1)!="/") {
|
||||
echo "The path must be absolute, for example /usr/local/bin/. Please type it again.";
|
||||
exit;
|
||||
}
|
||||
if ($_POST["DISCOVERY_CONFIG_FILE"] == "" ) $_POST["DISCOVERY_CONFIG_FILE"]="discovery.conf";
|
||||
putenv('DISCOVERY_DIR='.$_POST["discovery_dir"]);
|
||||
putenv('DISCOVERY_CONFIG_FILE='.$_POST["discovery_config_file"]);
|
||||
}
|
||||
|
||||
|
||||
putenv('ADDITIONALS='.$_POST["additionals"]);
|
||||
if ($_POST["additionals"]=="yes") {
|
||||
if ($_POST["SERVICE_DIR"] == "" ) $_POST["SERVICE_DIR"]="/etc/user/config/services";
|
||||
putenv('SERVICE_DIR='.$_POST["service_dir"]);
|
||||
|
||||
putenv('NEXTCLOUD='.$_POST["nextcloud"]);
|
||||
putenv('BITWARDEN='.$_POST["bitwarden"]);
|
||||
putenv('GUACAMOLE='.$_POST["guacamole"]);
|
||||
putenv('SMTP='.$_POST["smtp_server"]);
|
||||
putenv('ROUNDCUBE='.$_POST["roundcube"]);
|
||||
|
||||
if ($_POST["nextcloud"]=="yes") {
|
||||
putenv('NEXTCLOUD_DOMAIN='.$_POST["nextcloud_domain"]);
|
||||
putenv('NEXTCLOUD_USERNAME='.$_POST["nextcloud_username"]);
|
||||
putenv('NEXTCLOUD_PASSWORD='.$_POST["nextcloud_password"]);
|
||||
}
|
||||
if ($_POST["bitwarden"]=="yes") {
|
||||
putenv('BITWARDEN_DOMAIN='.$_POST["bitwarden_domain"]);
|
||||
putenv('SMTP_SERVER='.$_POST["bitwarden_smtp_server"]);
|
||||
putenv('SMTP_HOST='.$_POST["bitwarden_smtp_host"]);
|
||||
putenv('SMTP_PORT='.$_POST["bitwarden_smtp_port"]);
|
||||
putenv('SMTP_SECURITY='.$_POST["bitwarden_smtp_security"]);
|
||||
putenv('SMTP_FROM='.$_POST["bitwarden_smtp_from"]);
|
||||
putenv('SMTP_USERNAME='.$_POST["bitwarden_smtp_username"]);
|
||||
putenv('SMTP_PASSWORD='.$_POST["bitwarden_smtp_password"]);
|
||||
putenv('DOMAINS_WHITELIST='.$_POST["bitwarden_domains_whitelist"]);
|
||||
}
|
||||
if ($_POST["guacamole"]=="yes") {
|
||||
putenv('GUACAMOLE_DOMAIN='.$_POST["bitwarden_domain"]);
|
||||
putenv('GUACAMOLE_ADMIN_NAME='.$_POST["bitwarden_smtp_username"]);
|
||||
putenv('GUACAMOLE_ADMIN_PASSWORD='.$_POST["bitwarden_smtp_password"]);
|
||||
if ($_POST["bitwarden_totp"]=="yes") putenv('TOTP_USE=true');
|
||||
if ($_POST["bitwarden_ban_duration"]=="") $_POST["bitwarden_ban_duration"]="5";
|
||||
putenv('BAN_DURATION='.$_POST["bitwarden_ban_duration"]);
|
||||
}
|
||||
if ($_POST["roundcube"]=="yes") {
|
||||
if ($_POST["roundcube_imap_port"]=="") $_POST["roundcube_imap_port"]="143";
|
||||
if ($_POST["roundcube_smtp_port"]=="") $_POST["roundcube_smtp_port"]="25";
|
||||
if ($_POST["roundcube_upload"]=="") $_POST["roundcube_smtp_port"]="50M";
|
||||
putenv('ROUNDCUBE_IMAP_HOST='.$_POST["roundcube_imap_host"]);
|
||||
putenv('ROUNDCUBE_IMAP_PORT='.$_POST["roundcube_imap_port"]);
|
||||
putenv('ROUNDCUBE_SMTP_HOST='.$_POST["roundcube_smtp_host"]);
|
||||
putenv('ROUNDCUBE_SMTP_PORT='.$_POST["roundcube_smtp_port"]);
|
||||
putenv('ROUNDCUBE_UPLOAD_MAX_FILESIZE='.$_POST["roundcube_upload"]);
|
||||
putenv('ROUNDCUBE_DOMAIN='.$_POST["roundcube_domain"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
66
index.html
66
index.html
@@ -25,18 +25,75 @@
|
||||
<div class="progress-value"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div><a href="install.html" class="stop">STOP</a></div>
|
||||
<div><a href="install.html" class="stop">STOP AND START INSTALL</a></div>
|
||||
<br>
|
||||
<br>
|
||||
<div id="redis"></div>
|
||||
<div id="previous"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 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://code.jquery.com/jquery-3.7.1.min.js"></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>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
setTimeout(redirectToPage, 10000);
|
||||
function redirectToInstall() {
|
||||
window.location.href = 'install.html';
|
||||
}
|
||||
|
||||
function redirectToManage() {
|
||||
window.location.href = 'manage.html';
|
||||
}
|
||||
|
||||
function start_init() {
|
||||
var url = 'scan.php?op=init';
|
||||
$.get(url, function(data){
|
||||
if (data=='OK') {
|
||||
$("#previous").html('Scanning for previous install. Please wait...');
|
||||
check_init();
|
||||
}
|
||||
else {
|
||||
$("#previous").html('Scanning for previous install has aborted...');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function check_init() {
|
||||
var url = 'scan.php?op=check_init';
|
||||
$.get(url, function(data){
|
||||
console.log(data);
|
||||
if (data=='NEW') {
|
||||
$("#previous").html('No previous install has found...');
|
||||
setTimeout(redirectToInstall, 3000);
|
||||
}
|
||||
else if (data=='EXISTS') {
|
||||
$("#previous").html('Previous install has found...');
|
||||
setTimeout(redirectToManage, 3000);
|
||||
}
|
||||
else if (data=='WAIT') {
|
||||
setTimeout(check_init, 1000);
|
||||
}
|
||||
else {
|
||||
// UNEXPECTED ERROR
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var url = 'scan.php?op=redis';
|
||||
$.get(url, function(data){
|
||||
if (data=='OK') {
|
||||
$("#redis").html('Redis server - OK');
|
||||
start_init();
|
||||
}
|
||||
else {
|
||||
$("#redis").html('Redis server is not available...');
|
||||
}
|
||||
});
|
||||
|
||||
//setTimeout(redirectToManage, 10000);
|
||||
|
||||
$(".progress").each(function() {
|
||||
|
||||
@@ -95,9 +152,6 @@ $(function() {
|
||||
return angle;
|
||||
}
|
||||
|
||||
function redirectToPage() {
|
||||
window.location.href = 'manage.html';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
88
install.html
88
install.html
@@ -22,7 +22,7 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="registry">Please fill in the docker registry name (default:registry.format.hu):</label>
|
||||
<input type="registry" class="form-control" name="registry" id="registry" value="registry.format.hu" required>
|
||||
<input type="registry" class="form-control" name="DOCKER_REGISTRY_URL" id="registry" value="registry.format.hu" required>
|
||||
<div class="invalid-feedback">
|
||||
Please enter a valid registry url.
|
||||
</div>
|
||||
@@ -31,7 +31,7 @@
|
||||
<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">
|
||||
<select class="custom-select d-block w-100" name="SMARTHOST_PROXY" id="smarthost">
|
||||
<option value="yes" selected>Yes</option>
|
||||
<option value="no">No</option>
|
||||
</select>
|
||||
@@ -41,7 +41,7 @@
|
||||
<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">
|
||||
<input type="domain" class="form-control" name="DOMAIN" id="domain" value="localhost">
|
||||
<div class="invalid-feedback">
|
||||
Please enter a valid domain.
|
||||
</div>
|
||||
@@ -51,7 +51,7 @@
|
||||
<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">
|
||||
<select class="custom-select d-block w-100" name="LOCAL_PROXY" id="localproxy">
|
||||
<option value="yes" selected>Yes</option>
|
||||
<option value="no">No</option>
|
||||
</select>
|
||||
@@ -60,7 +60,7 @@
|
||||
<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">
|
||||
<select class="custom-select d-block w-100" name="VPN_PROXY" id="vpn">
|
||||
<option value="yes">Yes</option>
|
||||
<option value="no" selected>No</option>
|
||||
</select>
|
||||
@@ -70,7 +70,7 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="vpn_domain">Please add domain url to download the VPN hash from (default: https://demo.format.hu):</label>
|
||||
<input type="text" class="form-control" name="vpn_domain" id="vpn_domain" value="https://demo.format.hu">
|
||||
<input type="text" class="form-control" name="VPN_DOMAIN" id="vpn_domain" value="https://demo.format.hu">
|
||||
<div class="invalid-feedback">
|
||||
Please enter a valid domain.
|
||||
</div>
|
||||
@@ -79,13 +79,13 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="vpn_key">Please type in the generated VPN passkey (8 digits):</label>
|
||||
<input type="text" class="form-control" name="vpn_key" id="vpn_key" value="" maxlength="8" size="10">
|
||||
<input type="text" class="form-control" name="VPN_KEY" id="vpn_key" value="" maxlength="8" size="10">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="letsencrypt_mail">Please add the letsencrypt mail address:</label>
|
||||
<input type="email" class="form-control" name="letsencrypt_mail" id="letsencrypt_mail" value="">
|
||||
<input type="email" class="form-control" name="LETSENCRYPT_MAIL" id="letsencrypt_mail" value="">
|
||||
<div class="invalid-feedback">
|
||||
Please enter a valid email.
|
||||
</div>
|
||||
@@ -94,14 +94,14 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="letsencrypt_servername">Please add letsencrypt server name (default is letsencrypt but you can add zerossl too):</label>
|
||||
<input type="text" class="form-control" name="letsencrypt_servername" id="letsencrypt_servername" value="letsencrypt">
|
||||
<input type="text" class="form-control" name="LETSENCRYPT_SERVERNAME" id="letsencrypt_servername" value="letsencrypt">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="cron">Cron?</label>
|
||||
<select class="custom-select d-block w-100" name="cron" id="cron">
|
||||
<select class="custom-select d-block w-100" name="CRON" id="cron">
|
||||
<option value="yes">Yes</option>
|
||||
<option value="no">No</option>
|
||||
</select>
|
||||
@@ -114,7 +114,7 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="discovery">Would you like to discover services?</label>
|
||||
<select class="custom-select d-block w-100" name="discovery" id="discovery">
|
||||
<select class="custom-select d-block w-100" name="DISCOVERY" id="discovery">
|
||||
<option value="yes" selected>Yes</option>
|
||||
<option value="no">No</option>
|
||||
</select>
|
||||
@@ -124,13 +124,13 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="discovery_dir">Path of service discovery scripts: (/usr/local/bin/)</label>
|
||||
<input type="text" class="form-control" name="discovery_dir" id="discovery_dir" value="/usr/local/bin/">
|
||||
<input type="text" class="form-control" name="DISCOVERY_DIR" id="discovery_dir" value="/usr/local/bin/">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="dicovery_config_file">Path of the discovery config file: (discovery.conf)</label>
|
||||
<input type="text" class="form-control" name="dicovery_config_file" id="dicovery_config_file" value="discovery.conf">
|
||||
<input type="text" class="form-control" name="DISCOVERY_CONFIG_FILE" id="dicovery_config_file" value="discovery.conf">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -141,7 +141,7 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="additionals">Would you like to install additional applications?</label>
|
||||
<select class="custom-select d-block w-100" name="additionals" id="additionals">
|
||||
<select class="custom-select d-block w-100" name="ADDITIONALS" id="additionals">
|
||||
<option value="yes">Yes</option>
|
||||
<option value="no" selected>No</option>
|
||||
</select>
|
||||
@@ -151,13 +151,13 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="service_dir">Please add directory path of service files: (/etc/user/config/services/)</label>
|
||||
<input type="text" class="form-control" name="service_dir" id="service_dir" value="/etc/user/config/services">
|
||||
<input type="text" class="form-control" name="SERVICE_DIR" id="service_dir" value="/etc/user/config/services">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="nextcloud">Do you want to install Nextcloud?</label>
|
||||
<select class="custom-select d-block w-100" name="nextcloud" id="nextcloud">
|
||||
<select class="custom-select d-block w-100" name="NEXTCLOUD" id="nextcloud">
|
||||
<option value="yes">Yes</option>
|
||||
<option value="no" selected>No</option>
|
||||
</select>
|
||||
@@ -168,26 +168,26 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="nextcloud_domain">Please add Nextcloud domain: </label>
|
||||
<input type="text" class="form-control" name="nextcloud_domain" id="nextcloud_domain" value="">
|
||||
<input type="text" class="form-control" name="NEXTCLOUD_DOMAIN" id="nextcloud_domain" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="nextcloud_username">Please add Nextcloud username: </label>
|
||||
<input type="text" class="form-control" name="nextcloud_username" id="nextcloud_username" value="">
|
||||
<input type="text" class="form-control" name="NEXTCLOUD_USERNAME" id="nextcloud_username" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="nextcloud_password">Please add Nextcloud password: </label>
|
||||
<input type="text" class="form-control" name="nextcloud_password" id="nextcloud_password" value="">
|
||||
<input type="text" class="form-control" name="NEXTCLOUD_PASSWORD" id="nextcloud_password" value="">
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="bitwarden">Do you want to install Bitwarden?</label>
|
||||
<select class="custom-select d-block w-100" name="bitwarden" id="bitwarden">
|
||||
<select class="custom-select d-block w-100" name="BITWARDEN" id="bitwarden">
|
||||
<option value="yes">Yes</option>
|
||||
<option value="no" selected>No</option>
|
||||
</select>
|
||||
@@ -198,13 +198,13 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="bitwarden_domain">Please add Bitwarden domain: </label>
|
||||
<input type="text" class="form-control" name="bitwarden_domain" id="bitwarden_domain" value="">
|
||||
<input type="text" class="form-control" name="BITWARDEN_DOMAIN" id="bitwarden_domain" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="bitwarden_smtp">Please choose an SMTP server: </label>
|
||||
<select class="custom-select d-block w-100" name="bitwarden_smtp" id="bitwarden_smtp">
|
||||
<select class="custom-select d-block w-100" name="BITWARDEN_SMTP" id="bitwarden_smtp">
|
||||
<option value="1" selected>Gmail</option>
|
||||
<option value="2">Microsoft Outlook/Hotmail</option>
|
||||
<option value="3">Other</option>
|
||||
@@ -215,51 +215,51 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="bitwarden_smtp_host">Please add SMTP HOST: </label>
|
||||
<input type="text" class="form-control" name="bitwarden_smtp_host" id="bitwarden_smtp_host" value="">
|
||||
<input type="text" class="form-control" name="BITWARDEN_SMTP_HOST" id="bitwarden_smtp_host" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="bitwarden_smtp_port">Please add SMTP PORT (587, 465, 25, etc.): </label>
|
||||
<input type="text" class="form-control" name="bitwarden_smtp_port" id="bitwarden_smtp_port" value="">
|
||||
<input type="text" class="form-control" name="BITWARDEN_SMTP_PORT" id="bitwarden_smtp_port" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="bitwarden_smtp_security">Please add SMTP SECURITY (starttls, force_tls, off, etc.): </label>
|
||||
<input type="text" class="form-control" name="bitwarden_smtp_security" id="bitwarden_smtp_security" value="">
|
||||
<input type="text" class="form-control" name="BITWARDEN_SMTP_SECURITY" id="bitwarden_smtp_security" value="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="bitwarden_smtp_host">Please add SMTP FROM (mail address from): </label>
|
||||
<input type="text" class="form-control" name="bitwarden_smtp_from" id="bitwarden_smtp_from" value="">
|
||||
<input type="text" class="form-control" name="BITWARDEN_SMTP_FROM" id="bitwarden_smtp_from" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="bitwarden_smtp_username">Please add SMTP USERNAME: </label>
|
||||
<input type="text" class="form-control" name="bitwarden_smtp_username" id="bitwarden_smtp_username" value="">
|
||||
<input type="text" class="form-control" name="BITWARDEN_SMTP_USERNAME" id="bitwarden_smtp_username" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="bitwarden_smtp_password">Please add SMTP PASSWORD: </label>
|
||||
<input type="text" class="form-control" name="bitwarden_smtp_password" id="bitwarden_smtp_password" value="">
|
||||
<input type="text" class="form-control" name="BITWARDEN_SMTP_PASSWORD" id="bitwarden_smtp_password" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="bitwarden_domains_whitelist">Please add Domains Whitelist (list of domains): </label>
|
||||
<input type="text" class="form-control" name="bitwarden_domains_whitelist" id="bitwarden_domains_whitelist" value="">
|
||||
<input type="text" class="form-control" name="BITWARDEN_DOMAINS_WHITELIST" id="bitwarden_domains_whitelist" value="">
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="guacamole">Do you want to install Guacamole?</label>
|
||||
<select class="custom-select d-block w-100" name="guacamole" id="guacamole">
|
||||
<select class="custom-select d-block w-100" name="GUACAMOLE" id="guacamole">
|
||||
<option value="yes">Yes</option>
|
||||
<option value="no" selected>No</option>
|
||||
</select>
|
||||
@@ -270,25 +270,25 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="guacamole_domain">Please add Guacamole domain: </label>
|
||||
<input type="text" class="form-control" name="guacamole_domain" id="guacamole_domain" value="">
|
||||
<input type="text" class="form-control" name="GUACAMOLE_DOMAIN" id="guacamole_domain" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="guacamole_username">Please add Guacamole admin username: </label>
|
||||
<input type="text" class="form-control" name="guacamole_username" id="guacamole_username" value="">
|
||||
<input type="text" class="form-control" name="GUACAMOLE_USERNAME" id="guacamole_username" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="guacamole_password">Please add Guacamole admin password: </label>
|
||||
<input type="text" class="form-control" name="guacamole_password" id="guacamole_password" value="">
|
||||
<input type="text" class="form-control" name="GUACAMOLE_PASSWORD" id="guacamole_password" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="guacemole_totp">Do you want TOTP via login? </label>
|
||||
<select class="custom-select d-block w-100" name="guacemole_totp" id="guacemole_totp">
|
||||
<select class="custom-select d-block w-100" name="GUACAMOLE_TOTP" id="guacamole_totp">
|
||||
<option value="yes" selected>Yes</option>
|
||||
<option value="no">No</option>
|
||||
</select>
|
||||
@@ -298,14 +298,14 @@
|
||||
<div class="mb-3">
|
||||
<label for="guacamole_ban_duration">Do you want limitation in case invalid login or password? Please add a number how many minutes for deny retry. If you add 0 means it will disabled.";
|
||||
</label>
|
||||
<input type="text" class="form-control" name="guacamole_ban_duration" id="guacamole_ban_duration" value="5">
|
||||
<input type="text" class="form-control" name="GUACAMOLE_BAN_DURATION" id="guacamole_ban_duration" value="5">
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="smtp_server">Do you want to install SMTP server?</label>
|
||||
<select class="custom-select d-block w-100" name="smtp_server" id="smtp_server">
|
||||
<select class="custom-select d-block w-100" name="SMTP_SERVER" id="smtp_server">
|
||||
<option value="yes">Yes</option>
|
||||
<option value="no" selected>No</option>
|
||||
</select>
|
||||
@@ -314,7 +314,7 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="roundcube">Do you want to install roundcube?</label>
|
||||
<select class="custom-select d-block w-100" name="roundcube" id="roundcube">
|
||||
<select class="custom-select d-block w-100" name="ROUNDCUBE" id="roundcube">
|
||||
<option value="yes">Yes</option>
|
||||
<option value="no" selected>No</option>
|
||||
</select>
|
||||
@@ -325,37 +325,37 @@
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="roundcube_imap_host">Please add IMAP HOST: </label>
|
||||
<input type="text" class="form-control" name="roundcube_imap_host" id="roundcube_imap_host" value="">
|
||||
<input type="text" class="form-control" name="ROUNDCUBE_IMAP_HOST" id="roundcube_imap_host" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="roundcube_imap_port">Please add IMAP PORT (default: 143): </label>
|
||||
<input type="text" class="form-control" name="roundcube_imap_port" id="roundcube_imap_port" value="143">
|
||||
<input type="text" class="form-control" name="ROUNDCUBE_IMAP_PORT" id="roundcube_imap_port" value="143">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="roundcube_smtp_host">Please add SMTP HOST: </label>
|
||||
<input type="text" class="form-control" name="roundcube_smtp_host" id="roundcube_smtp_host" value="">
|
||||
<input type="text" class="form-control" name="ROUNDCUBE_SMTP_HOST" id="roundcube_smtp_host" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="roundcube_smtp_port">Please add SMTP PORT (587, 465, 25, etc., default: 25): </label>
|
||||
<input type="text" class="form-control" name="roundcube_smtp_port" id="roundcube_smtp_port" value="25">
|
||||
<input type="text" class="form-control" name="ROUNDCUBE_SMTP_PORT" id="roundcube_smtp_port" value="25">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="roundcube_upload">Please add UPLOAD_MAX_FILESIZE (default: 50M): </label>
|
||||
<input type="text" class="form-control" name="roundcube_upload" id="roundcube_upload" value="50M">
|
||||
<input type="text" class="form-control" name="ROUNDCUBE_UPLOAD" id="roundcube_upload" value="50M">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="mb-3">
|
||||
<label for="roundcube_domain">Please add Roundcube DOMAIN: </label>
|
||||
<input type="text" class="form-control" name="roundcube_domain" id="roundcube_domain" value="">
|
||||
<input type="text" class="form-control" name="ROUNDCUBE_DOMAIN" id="roundcube_domain" value="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -376,7 +376,7 @@
|
||||
<script>
|
||||
jQuery(document).ready(function(){
|
||||
|
||||
jQuery('select#smarthost').click(function() {
|
||||
jQuery('select#smarthost').change(function() {
|
||||
if (jQuery(this).val()=='yes') jQuery('#div_smarthost').show();
|
||||
else jQuery('#div_smarthost').hide();
|
||||
|
||||
|
152
install.php
152
install.php
@@ -1,95 +1,41 @@
|
||||
<?php
|
||||
include "functions.php";
|
||||
|
||||
// TEMP
|
||||
putenv('HOME=/home/hael');
|
||||
putenv('USER=hael');
|
||||
|
||||
putenv('DOCKER_REGISTRY_URL='.$_POST["registry"]);
|
||||
|
||||
putenv('SMARTHOST_PROXY='.$_POST["smarthost"]);
|
||||
if ($_POST["smarthost"]=="Y") {
|
||||
if ($_POST["domain"]=="") $_POST["domain"] = "localhost";
|
||||
putenv('DOMAIN='.$_POST["domain"]);
|
||||
if ($_POST["SMARTHOST_PROXY"]=="Y") {
|
||||
if ($_POST["DOMAIN"]=="") $_POST["DOMAIN"] = "localhost";
|
||||
# if not FQDN
|
||||
$arr = explode(".",$_POST["DOMAIN"]);
|
||||
if (count($arr)==1) {
|
||||
echo "Warning! It seems DOMAAIN is not an FQDN. Self-signed certificate will be created only.";
|
||||
putenv('SELF_SIGNED_CERTIFICATE=true');
|
||||
$_POST["SELF_SIGNED_CERTIFICATE"] = "true";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
putenv('LOCAL_PROXY='.$_POST["localproxy"]);
|
||||
putenv('LETSENCRYPT_MAIL='.$_POST["letsencrypt_mail"]);
|
||||
putenv('LETSENCRYPT_SERVERNAME='.$_POST["letsencrypt_servername"]);
|
||||
putenv('VPN_PROXY='.$_POST["vpn"]);
|
||||
if ($_POST["vpn"]=="yes") {
|
||||
putenv('VPN_DOMAIN='.$_POST["vpn_domain"]);
|
||||
putenv('VPN_KEY='.$_POST["vpn_key"]);
|
||||
|
||||
putenv('LETSENCRYPT_MAIL='.$_POST["letsencrypt_mail"]);
|
||||
putenv('LETSENCRYPT_SERVERNAME='.$_POST["letsencrypt_servername"]);
|
||||
}
|
||||
|
||||
if ($_POST["discovery"]=="yes") {
|
||||
if ($_POST["DISCOVERY"]=="yes") {
|
||||
if ($_POST["DISCOVERY_DIR"] == "" ) $_POST["DISCOVERY_DIR"]="/usr/local/bin/";
|
||||
if (substr($_POST["DISCOVERY_DIR"],0,1)!="/") {
|
||||
echo "The path must be absolute, for example /usr/local/bin/. Please type it again.";
|
||||
exit;
|
||||
}
|
||||
if ($_POST["DISCOVERY_CONFIG_FILE"] == "" ) $_POST["DISCOVERY_CONFIG_FILE"]="discovery.conf";
|
||||
putenv('DISCOVERY_DIR='.$_POST["discovery_dir"]);
|
||||
putenv('DISCOVERY_CONFIG_FILE='.$_POST["discovery_config_file"]);
|
||||
}
|
||||
|
||||
|
||||
putenv('ADDITIONALS='.$_POST["additionals"]);
|
||||
if ($_POST["additionals"]=="yes") {
|
||||
if ($_POST["ADDITIONALS"]=="yes") {
|
||||
if ($_POST["SERVICE_DIR"] == "" ) $_POST["SERVICE_DIR"]="/etc/user/config/services";
|
||||
putenv('SERVICE_DIR='.$_POST["service_dir"]);
|
||||
}
|
||||
|
||||
putenv('NEXTCLOUD='.$_POST["nextcloud"]);
|
||||
putenv('BITWARDEN='.$_POST["bitwarden"]);
|
||||
putenv('GUACAMOLE='.$_POST["guacamole"]);
|
||||
putenv('SMTP='.$_POST["smtp_server"]);
|
||||
putenv('ROUNDCUBE='.$_POST["roundcube"]);
|
||||
$json = json_encode($_POST, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
|
||||
//echo $json;
|
||||
|
||||
if ($_POST["nextcloud"]=="yes") {
|
||||
putenv('NEXTCLOUD_DOMAIN='.$_POST["nextcloud_domain"]);
|
||||
putenv('NEXTCLOUD_USERNAME='.$_POST["nextcloud_username"]);
|
||||
putenv('NEXTCLOUD_PASSWORD='.$_POST["nextcloud_password"]);
|
||||
}
|
||||
if ($_POST["bitwarden"]=="yes") {
|
||||
putenv('BITWARDEN_DOMAIN='.$_POST["bitwarden_domain"]);
|
||||
putenv('SMTP_SERVER='.$_POST["bitwarden_smtp_server"]);
|
||||
putenv('SMTP_HOST='.$_POST["bitwarden_smtp_host"]);
|
||||
putenv('SMTP_PORT='.$_POST["bitwarden_smtp_port"]);
|
||||
putenv('SMTP_SECURITY='.$_POST["bitwarden_smtp_security"]);
|
||||
putenv('SMTP_FROM='.$_POST["bitwarden_smtp_from"]);
|
||||
putenv('SMTP_USERNAME='.$_POST["bitwarden_smtp_username"]);
|
||||
putenv('SMTP_PASSWORD='.$_POST["bitwarden_smtp_password"]);
|
||||
putenv('DOMAINS_WHITELIST='.$_POST["bitwarden_domains_whitelist"]);
|
||||
}
|
||||
if ($_POST["guacamole"]=="yes") {
|
||||
putenv('GUACAMOLE_DOMAIN='.$_POST["bitwarden_domain"]);
|
||||
putenv('GUACAMOLE_ADMIN_NAME='.$_POST["bitwarden_smtp_username"]);
|
||||
putenv('GUACAMOLE_ADMIN_PASSWORD='.$_POST["bitwarden_smtp_password"]);
|
||||
if ($_POST["bitwarden_totp"]=="yes") putenv('TOTP_USE=true');
|
||||
if ($_POST["bitwarden_ban_duration"]=="") $_POST["bitwarden_ban_duration"]="5";
|
||||
putenv('BAN_DURATION='.$_POST["bitwarden_ban_duration"]);
|
||||
}
|
||||
if ($_POST["roundcube"]=="yes") {
|
||||
if ($_POST["roundcube_imap_port"]=="") $_POST["roundcube_imap_port"]="143";
|
||||
if ($_POST["roundcube_smtp_port"]=="") $_POST["roundcube_smtp_port"]="25";
|
||||
if ($_POST["roundcube_upload"]=="") $_POST["roundcube_smtp_port"]="50M";
|
||||
putenv('ROUNDCUBE_IMAP_HOST='.$_POST["roundcube_imap_host"]);
|
||||
putenv('ROUNDCUBE_IMAP_PORT='.$_POST["roundcube_imap_port"]);
|
||||
putenv('ROUNDCUBE_SMTP_HOST='.$_POST["roundcube_smtp_host"]);
|
||||
putenv('ROUNDCUBE_SMTP_PORT='.$_POST["roundcube_smtp_port"]);
|
||||
putenv('ROUNDCUBE_UPLOAD_MAX_FILESIZE='.$_POST["roundcube_upload"]);
|
||||
putenv('ROUNDCUBE_DOMAIN='.$_POST["roundcube_domain"]);
|
||||
}
|
||||
}
|
||||
// TODO preview about selected options?
|
||||
// TODO - new install in progress?
|
||||
|
||||
$key = "install:".date("YmdHis");
|
||||
redis_set($key,$json);
|
||||
|
||||
/*
|
||||
put_install_envs();
|
||||
|
||||
// check ENV variables
|
||||
$output = shell_exec("set");
|
||||
@@ -97,5 +43,69 @@ echo "<pre>".$output."</pre>";
|
||||
|
||||
//$output = shell_exec("sh install.sh");
|
||||
//echo $output;
|
||||
*/
|
||||
|
||||
?>
|
||||
<!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="install" class="text-center">
|
||||
<div class="container-fluid">
|
||||
<div class="col-md-12">
|
||||
<h1>Installing in progress... Please wait...</h1>
|
||||
<div id="redis"></div>
|
||||
<div id="response"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Optional JavaScript -->
|
||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></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>
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
function redirectToManage() {
|
||||
window.location.href = 'manage.html';
|
||||
}
|
||||
|
||||
function check_install() {
|
||||
var url = 'scan.php?op=check_install&key=<?php echo $key;?>';
|
||||
$.get(url, function(data){
|
||||
console.log(data);
|
||||
if (data=='INSTALLED') {
|
||||
redirectToManage();
|
||||
}
|
||||
else {
|
||||
$("#previous").html('Please wait...');
|
||||
setTimeout(redirectToInstall, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var url = 'scan.php?op=redis';
|
||||
$.get(url, function(data){
|
||||
if (data=='OK') {
|
||||
$("#redis").html('Redis server - OK');
|
||||
check_install();
|
||||
}
|
||||
else {
|
||||
$("#redis").html('Redis server is not available...');
|
||||
}
|
||||
});
|
||||
|
||||
//setTimeout(redirectToManage, 10000);
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
516
install.sh
516
install.sh
@@ -1,516 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
ask_envs() {
|
||||
echo "VPN proxy? (Y/n)";
|
||||
read -r ANSWER;
|
||||
if [ "$ANSWER" == "n" ] || [ "$ANSWER" == "N" ]; then
|
||||
VPN_PROXY="no";
|
||||
else
|
||||
VPN_PROXY="yes";
|
||||
|
||||
|
||||
if [ "$VPN_PASS" != "" ]; then
|
||||
dateFromServer=$(curl -v --silent https://demo.format.hu/ 2>&1 | grep -i '< date' | sed -e 's/< date: //gi')
|
||||
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;
|
||||
|
||||
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
|
||||
if [ "$LETSENCRYPT_SERVERNAME" = "" ]; then
|
||||
LETSENCRYPT_SERVERNAME="letsencrypt";
|
||||
fi;
|
||||
fi;
|
||||
fi
|
||||
}
|
||||
|
||||
discover_services() {
|
||||
if [ "$DISCOVERY" == "yes" ]; then
|
||||
if [ "$DISCOVERY_CONFIG_FILE" == "discovery.conf" ] ; then
|
||||
DISCOVERY_CONFIG_FILE=$PWD"/discovery.conf";
|
||||
if [ ! -f $DISCOVERY_CONFIG_FILE ]; then
|
||||
USE_SUDO=$(whoami);
|
||||
if [ "$USE_SUDO" == "root" ]; then
|
||||
USE_SUDO=0;
|
||||
else
|
||||
USE_SUDO=1;
|
||||
fi
|
||||
|
||||
{
|
||||
echo '#!/bin/bash';
|
||||
echo 'SOURCE_DIRS="/etc/user/data/ /etc/user/config/"; # separator space or |';
|
||||
echo 'DIRNAME="services misc"; # separator space or |';
|
||||
echo 'FILENAME="service healthcheck"; # separator space or |';
|
||||
echo 'KEYS="START_ON_BOOT"; # separator space or |';
|
||||
echo 'DEST_FILE="results.txt";';
|
||||
echo 'USE_SUDO='$USE_SUDO';';
|
||||
|
||||
} >> $DISCOVERY_CONFIG_FILE;
|
||||
fi
|
||||
fi
|
||||
DISCOVERY_CONFIG_DIR=$(dirname $DISCOVERY_CONFIG_FILE)
|
||||
if [ "$DISCOVERY_CONFIG_DIR" == "/root" ]; then
|
||||
DISCOVERY_CONFIG_DIR="";
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
check_dirs_and_files() { # TODO?
|
||||
|
||||
if [ ! -f "$HOME/.ssh/installer" ]; then
|
||||
echo "No ssh key files found. Please paste base64 content of the installer private key: ";
|
||||
while read -r INSTALLER; do
|
||||
if [ "$INSTALLER" != "" ]; then
|
||||
break;
|
||||
fi;
|
||||
done
|
||||
echo $INSTALLER > $HOME/.ssh/installer;
|
||||
fi;
|
||||
chmod 0600 $HOME/.ssh/installer;
|
||||
|
||||
if [ ! -d "/etc/user/config" ]; then
|
||||
$SUDO_CMD mkdir -p "/etc/user/config"
|
||||
fi;
|
||||
if [ ! -d "/etc/system" ]; then
|
||||
$SUDO_CMD mkdir "/etc/system"
|
||||
fi;
|
||||
if [ ! -d "/etc/user/secret" ]; then
|
||||
$SUDO_CMD mkdir -p "/etc/user/secret"
|
||||
fi;
|
||||
|
||||
if [ ! -f "/etc/user/config/system.json" ]; then
|
||||
{
|
||||
echo '
|
||||
{
|
||||
"NETWORK": {
|
||||
"IP_POOL_START": "172.19.0.0",
|
||||
"IP_POOL_END": "172.19.254.0",
|
||||
"IP_SUBNET": "24"
|
||||
}
|
||||
}
|
||||
';
|
||||
} > /tmp/system.json
|
||||
|
||||
$SUDO_CMD mv /tmp/system.json /etc/user/config/system.json
|
||||
fi;
|
||||
|
||||
{
|
||||
echo "alias service-debian='$SUDO_CMD docker run --rm \
|
||||
-w /services/ \
|
||||
-e DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL \
|
||||
-e USER_INIT_PATH=/etc/user/config \
|
||||
-e CA_PATH=/etc/ssl/certs \
|
||||
-e DNS_DIR=/etc/system/data/dns \
|
||||
-e HOST_FILE=/etc/dns/hosts.local \
|
||||
-v /etc/system/data/dns:/etc/dns:rw \
|
||||
-v /etc/ssl/certs:/etc/ssl/certs:ro \
|
||||
-v /etc/user/config/user.json:/etc/user/config/user.json:ro \
|
||||
-v /etc/user/config/system.json:/etc/user/config/system.json:ro \
|
||||
-v /etc/user/config/services/:/services/:ro \
|
||||
-v /etc/user/config/services/tmp:/services/tmp:rw \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v /usr/bin/docker:/usr/bin/docker:ro \
|
||||
$DOCKER_REGISTRY_URL/setup'";
|
||||
} > $HOME/.bash_aliases
|
||||
|
||||
}
|
||||
|
||||
check_running() {
|
||||
|
||||
DOCKERD_STATUS="0";
|
||||
|
||||
### From Redis
|
||||
# bridge check
|
||||
BRIDGE_NUM=$($SUDO_CMD docker network ls | grep bridge | awk '{print $2":"$3}' | sort | uniq | wc -l);
|
||||
|
||||
CONTAINER_NUM=$($SUDO_CMD docker ps -a | wc -l);
|
||||
|
||||
if [ "$BRIDGE_NUM" != "1" ] && [ "$CONTAINER_NUM" != "1" ]; then
|
||||
|
||||
echo "There are existing containers and/or networks.";
|
||||
echo "Please select from the following options (1/2/3):";
|
||||
|
||||
echo "1 - Delete all existing containers and networks before installation";
|
||||
echo "2 - Stop the installation process";
|
||||
echo "3 - Just continue on my own risk";
|
||||
|
||||
read -r ANSWER;
|
||||
|
||||
if [ "$ANSWER" == "1" ]; then
|
||||
echo "1 - Removing exising containers and networks";
|
||||
# delete and continue
|
||||
$SUDO_CMD docker stop $($SUDO_CMD docker ps |grep Up | awk '{print $1}')
|
||||
$SUDO_CMD docker system prune -a
|
||||
|
||||
elif [ "$ANSWER" == "3" ]; then
|
||||
echo "3 - You have chosen to continue installation process."
|
||||
|
||||
else # default: 2 - stop installastion
|
||||
echo "2 - Installation process was stopped";
|
||||
exit;
|
||||
fi;
|
||||
|
||||
fi;
|
||||
# visszairni redis - ha redisbol minden 1, akkor manager mode
|
||||
}
|
||||
|
||||
SUDO_CMD="";
|
||||
|
||||
# first install
|
||||
if [ ! -f "/etc/user/config/system.json" ]; then
|
||||
|
||||
INIT="true";
|
||||
|
||||
check_running;
|
||||
|
||||
check_dirs_and_files;
|
||||
|
||||
discover_services;
|
||||
|
||||
# base variables
|
||||
|
||||
if [ "$DOCKER_REGISTRY_URL" != "" ]; then
|
||||
VAR_DOCKER_REGISTRY_URL="--env DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL";
|
||||
fi
|
||||
|
||||
if [ "$SMARTHOST_PROXY" != "" ]; then
|
||||
VAR_SMARTHOST_PROXY="--env SMARTHOST_PROXY=$SMARTHOST_PROXY";
|
||||
fi
|
||||
|
||||
if [ "$LOCAL_PROXY" != "" ]; then
|
||||
VAR_LOCAL_PROXY="--env LOCAL_PROXY=$LOCAL_PROXY";
|
||||
fi
|
||||
|
||||
if [ "$VPN_PROXY" != "" ]; then
|
||||
VAR_VPN_PROXY="--env VPN_PROXY=$VPN_PROXY";
|
||||
fi
|
||||
|
||||
if [ "$DOMAIN" != "" ]; then
|
||||
VAR_DOMAIN="--env DOMAIN=$DOMAIN";
|
||||
fi
|
||||
|
||||
if [ "$CRON" != "" ]; then
|
||||
VAR_CRON="--env CRON=$CRON";
|
||||
fi
|
||||
|
||||
# discovery
|
||||
|
||||
if [ "$DISCOVERY" != "" ]; then
|
||||
VAR_DISCOVERY="--env DISCOVERY=$DISCOVERY";
|
||||
fi
|
||||
|
||||
if [ "$DISCOVERY_DIR" != "" ]; then
|
||||
VAR_DISCOVERY_DIR="--env DISCOVERY_DIR=$DISCOVERY_DIR";
|
||||
VAR_DISCOVERY_DIRECTORY="--volume $DISCOVERY_DIR/:$DISCOVERY_DIR/";
|
||||
fi
|
||||
|
||||
if [ "$DISCOVERY_CONFIG_FILE" != "" ]; then
|
||||
VAR_DISCOVERY_CONFIG_FILE="--env DISCOVERY_CONFIG_FILE=$DISCOVERY_CONFIG_FILE";
|
||||
if [ "$DISCOVERY_CONFIG_DIR" != "" ]; then
|
||||
VAR_DISCOVERY_CONFIG_DIRECTORY="--volume $DISCOVERY_CONFIG_DIR/:$DISCOVERY_CONFIG_DIR/";
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run installer tool
|
||||
|
||||
$SUDO_CMD docker run \
|
||||
$VAR_DOCKER_REGISTRY_URL \
|
||||
$VAR_SMARTHOST_PROXY \
|
||||
$VAR_LOCAL_PROXY \
|
||||
$VAR_VPN_PROXY \
|
||||
$VAR_DOMAIN \
|
||||
$VAR_CRON \
|
||||
$VAR_DISCOVERY \
|
||||
$VAR_DISCOVERY_DIR \
|
||||
$VAR_DISCOVERY_DIRECTORY \
|
||||
$VAR_DISCOVERY_CONFIG_FILE \
|
||||
$VAR_DISCOVERY_CONFIG_DIRECTORY \
|
||||
--volume $HOME/.ssh/installer:/root/.ssh/id_rsa \
|
||||
--volume /etc/user/:/etc/user/ \
|
||||
--volume /etc/system/:/etc/system/ \
|
||||
--env LETSENCRYPT_MAIL=$LETSENCRYPT_MAIL \
|
||||
--env LETSENCRYPT_SERVERNAME=$LETSENCRYPT_SERVERNAME \
|
||||
$DOCKER_REGISTRY_URL/installer-tool
|
||||
else
|
||||
|
||||
$SUDO_CMD docker pull $DOCKER_REGISTRY_URL/installer-tool
|
||||
$SUDO_CMD docker pull $DOCKER_REGISTRY_URL/setup
|
||||
|
||||
fi;
|
||||
|
||||
# test - alias doesn't work inside a function
|
||||
# must be outside of if
|
||||
shopt -s expand_aliases
|
||||
source $HOME/.bash_aliases
|
||||
|
||||
if [ "$INIT" == "true" ]; then
|
||||
|
||||
INIT_SERVICE_PATH=/etc/user/config/services
|
||||
|
||||
type -a service-debian
|
||||
|
||||
service-debian core-dns start
|
||||
echo "$INIT_SERVICE_PATH/core-dns.json" >> $PWD/.init_services
|
||||
|
||||
if [ "$CRON" == "yes" ]; then
|
||||
service-debian cron start
|
||||
echo "$INIT_SERVICE_PATH/cron.json" >> $PWD/.init_services
|
||||
fi
|
||||
|
||||
if [ "$VPN_PROXY" == "yes" ]; then
|
||||
service-debian vpn-proxy start
|
||||
echo "$INIT_SERVICE_PATH/vpn-proxy.json" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/firewall-vpn-smarthost-loadbalancer" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/firewall-vpn-proxy-postrouting" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/firewall-vpn-proxy-prerouting" >> $PWD/.init_services
|
||||
|
||||
fi
|
||||
|
||||
if [ "$SMARTHOST_PROXY" == "yes" ]; then
|
||||
service-debian smarthost-proxy start
|
||||
service-debian smarthost-proxy-scheduler start
|
||||
service-debian local-proxy start
|
||||
|
||||
echo "$INIT_SERVICE_PATH/smarthost-proxy.json" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/firewall-smarthost-loadbalancer-dns.json" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/firewall-letsencrypt.json" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/firewall-smarthostloadbalancer-from-publicbackend.json" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/firewall-smarthost-backend-dns.json" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/firewall-smarthost-to-backend.json" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/smarthost-proxy-scheduler.json" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/local-proxy.json" >> $PWD/.init_services
|
||||
|
||||
echo "Would you like to run local backend? (Y/n)";
|
||||
read -r ANSWER;
|
||||
if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then
|
||||
service-debian local-backend start
|
||||
echo "$INIT_SERVICE_PATH/local-backend.json" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/firewall-local-backend.json" >> $PWD/.init_services
|
||||
echo "$INIT_SERVICE_PATH/domain-local-backend.json" >> $PWD/.init_services
|
||||
fi
|
||||
fi
|
||||
|
||||
fi;
|
||||
|
||||
# install additionals - run installer-tool again but additional_install.sh instead of deploy.sh
|
||||
if [ "$ADDITIONALS" == "yes" ]; then
|
||||
|
||||
ADDITIONAL_SERVICES="";
|
||||
|
||||
if [ "$NEXTCLOUD" == "yes" ]; then
|
||||
VAR_NEXTCLOUD="--env NEXTCLOUD=$NEXTCLOUD";
|
||||
VAR_NEXTCLOUD="$VAR_NEXTCLOUD --env NEXTCLOUD_DOMAIN=$NEXTCLOUD_DOMAIN";
|
||||
VAR_NEXTCLOUD="$VAR_NEXTCLOUD --env NEXTCLOUD_USERNAME=$NEXTCLOUD_USERNAME";
|
||||
VAR_NEXTCLOUD="$VAR_NEXTCLOUD --env NEXTCLOUD_PASSWORD=$NEXTCLOUD_PASSWORD";
|
||||
|
||||
if [ ! -d "/etc/user/data/nextcloud" ]; then
|
||||
for DIR in data apps config ; do
|
||||
$SUDO_CMD mkdir -p "/etc/user/data/nextcloud/$DIR"
|
||||
$SUDO_CMD chown -R 82:82 "/etc/user/data/nextcloud/$DIR"
|
||||
done
|
||||
fi;
|
||||
|
||||
echo "Would you like to run Nextcloud after install? (Y/n)";
|
||||
read -r ANSWER;
|
||||
if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then
|
||||
ADDITIONAL_SERVICES="$ADDITIONAL_SERVICES nextcloud";
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$BITWARDEN" == "yes" ]; then
|
||||
VAR_BITWARDEN="--env BITWARDEN=$BITWARDEN";
|
||||
VAR_BITWARDEN="$VAR_BITWARDEN --env BITWARDEN_DOMAIN=$BITWARDEN_DOMAIN";
|
||||
VAR_BITWARDEN="$VAR_BITWARDEN --env SMTP_SERVER=$SMTP_SERVER";
|
||||
VAR_BITWARDEN="$VAR_BITWARDEN --env SMTP_HOST=$SMTP_HOST";
|
||||
VAR_BITWARDEN="$VAR_BITWARDEN --env SMTP_PORT=$SMTP_PORT";
|
||||
VAR_BITWARDEN="$VAR_BITWARDEN --env SMTP_SECURITY=$SMTP_SECURITY";
|
||||
VAR_BITWARDEN="$VAR_BITWARDEN --env SMTP_FROM=$SMTP_FROM";
|
||||
VAR_BITWARDEN="$VAR_BITWARDEN --env SMTP_USERNAME=$SMTP_USERNAME";
|
||||
VAR_BITWARDEN="$VAR_BITWARDEN --env SMTP_PASSWORD=$SMTP_PASSWORD";
|
||||
VAR_BITWARDEN="$VAR_BITWARDEN --env DOMAINS_WHITELIST=$DOMAINS_WHITELIST";
|
||||
|
||||
echo " ";
|
||||
echo "######################################################################################";
|
||||
echo "# You can access your bitwarden admin page here: https://$BITWARDEN_DOMAIN/admin #";
|
||||
echo "# You will find ADMIN TOKEN in this file: /etc/user/secret/bitwarden.json #";
|
||||
echo "######################################################################################";
|
||||
echo " ";
|
||||
echo "Would you like to run Bitwarden after install? (Y/n)";
|
||||
|
||||
read -r ANSWER;
|
||||
if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then
|
||||
ADDITIONAL_SERVICES="$ADDITIONAL_SERVICES bitwarden";
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$GUACAMOLE" == "yes" ]; then
|
||||
VAR_GUACAMOLE="--env GUACAMOLE=$GUACAMOLE";
|
||||
VAR_GUACAMOLE="$VAR_GUACAMOLE --env GUACAMOLE_DOMAIN=$GUACAMOLE_DOMAIN";
|
||||
VAR_GUACAMOLE="$VAR_GUACAMOLE --env GUACAMOLE_ADMIN_NAME=$GUACAMOLE_ADMIN_NAME";
|
||||
VAR_GUACAMOLE="$VAR_GUACAMOLE --env GUACAMOLE_ADMIN_PASSWORD=$GUACAMOLE_ADMIN_PASSWORD";
|
||||
VAR_GUACAMOLE="$VAR_GUACAMOLE --env TOTP_USE=$TOTP_USE";
|
||||
VAR_GUACAMOLE="$VAR_GUACAMOLE --env BAN_DURATION=$BAN_DURATION";
|
||||
|
||||
echo "Would you like to run Guacamole after install? (Y/n)";
|
||||
read -r ANSWER;
|
||||
if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then
|
||||
ADDITIONAL_SERVICES="$ADDITIONAL_SERVICES guacamole";
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$SMTP" == "yes" ]; then
|
||||
VAR_SMTP="--env SMTP=$SMTP";
|
||||
|
||||
echo "Would you like to run SMTP after install? (Y/n)";
|
||||
read -r ANSWER;
|
||||
if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then
|
||||
ADDITIONAL_SERVICES="$ADDITIONAL_SERVICES smtp";
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$ROUNDCUBE" == "yes" ]; then
|
||||
VAR_ROUNDCUBE="--env ROUNDCUBE=$ROUNDCUBE";
|
||||
VAR_ROUNDCUBE="$VAR_ROUNDCUBE --env ROUNDCUBE_IMAP_HOST=$ROUNDCUBE_IMAP_HOST";
|
||||
VAR_ROUNDCUBE="$VAR_ROUNDCUBE --env ROUNDCUBE_IMAP_PORT=$ROUNDCUBE_IMAP_PORT";
|
||||
VAR_ROUNDCUBE="$VAR_ROUNDCUBE --env ROUNDCUBE_SMTP_HOST=$ROUNDCUBE_SMTP_HOST";
|
||||
VAR_ROUNDCUBE="$VAR_ROUNDCUBE --env ROUNDCUBE_SMTP_PORT=$ROUNDCUBE_SMTP_PORT";
|
||||
VAR_ROUNDCUBE="$VAR_ROUNDCUBE --env ROUNDCUBE_UPLOAD_MAX_FILESIZE=$ROUNDCUBE_UPLOAD_MAX_FILESIZE";
|
||||
VAR_ROUNDCUBE="$VAR_ROUNDCUBE --env ROUNDCUBE_DOMAIN=$ROUNDCUBE_DOMAIN";
|
||||
|
||||
echo "Would you like to run roundcube after install? (Y/n)";
|
||||
read -r ANSWER;
|
||||
if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then
|
||||
ADDITIONAL_SERVICES="$ADDITIONAL_SERVICES roundcube";
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run installer tool
|
||||
$SUDO_CMD docker run \
|
||||
--env ADDITIONALS=true \
|
||||
--env SERVICE_DIR=$SERVICE_DIR\
|
||||
$VAR_NEXTCLOUD \
|
||||
$VAR_BITWARDEN \
|
||||
$VAR_GUACAMOLE \
|
||||
$VAR_SMTP \
|
||||
$VAR_ROUNDCUBE \
|
||||
--volume $HOME/.ssh/installer:/root/.ssh/id_rsa \
|
||||
--volume /etc/user/:/etc/user/ \
|
||||
--volume /etc/system/:/etc/system/ \
|
||||
$DOCKER_REGISTRY_URL/installer-tool
|
||||
fi
|
||||
|
||||
shopt -s expand_aliases
|
||||
source $HOME/.bash_aliases
|
||||
|
||||
if [ "$ADDITIONAL_SERVICES" != "" ]; then
|
||||
for ADDITIONAL_SERVICE in $(echo $ADDITIONAL_SERVICES); do
|
||||
service-debian $ADDITIONAL_SERVICE start
|
||||
echo "$INIT_SERVICE_PATH/$ADDITIONAL_SERVICE.json" >> $PWD/.init_services
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$DISCOVERY" != "yes" ] ; then
|
||||
discover_services;
|
||||
fi;
|
||||
|
||||
if [ "$DISCOVERY" == "yes" ] ; then
|
||||
$SUDO_CMD chmod a+x $DISCOVERY_DIR/service-discovery.sh
|
||||
$DISCOVERY_DIR/service-discovery.sh $DISCOVERY_CONFIG_FILE;
|
||||
source $DISCOVERY_CONFIG_FILE;
|
||||
cat $DEST_FILE;
|
||||
|
||||
echo "Would you like to run discovered services? (Y/n)";
|
||||
read -r ANSWER;
|
||||
if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then
|
||||
$SUDO_CMD chmod a+x $DISCOVERY_DIR/service-files.sh
|
||||
$DISCOVERY_DIR/service-files.sh $DEST_FILE &
|
||||
fi;
|
||||
fi;
|
||||
|
||||
if [ "$DEBIAN" == "true" ] || [ "$GENTOO" == "true" ] ; then
|
||||
|
||||
echo "Do you want to start the discovered and actually started services at the next time when your system restarting? (Y/n)";
|
||||
read -r ANSWER;
|
||||
if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then
|
||||
|
||||
cp $DISCOVERY_CONFIG_FILE $DISCOVERY_CONFIG_FILE".copy";
|
||||
cp $DEST_FILE $DEST_FILE".copy";
|
||||
|
||||
DISCOVERY_CONFIG_FILENAME=$(basename $DISCOVERY_CONFIG_FILE);
|
||||
source $DISCOVERY_CONFIG_FILE;
|
||||
{
|
||||
echo '#!/bin/bash';
|
||||
echo 'SOURCE_DIRS="'$SOURCE_DIRS'"; # separator space or |';
|
||||
echo 'DIRNAME="'$DIRNAME'"; # separator space or |';
|
||||
echo 'FILENAME="'$FILENAME'"; # separator space or |';
|
||||
echo 'KEYS="'$KEYS'"; # separator space or |';
|
||||
echo 'DEST_FILE="/usr/local/etc/results.txt";';
|
||||
echo 'USE_SUDO=0;';
|
||||
} > /tmp/$DISCOVERY_CONFIG_FILENAME
|
||||
|
||||
$SUDO_CMD mkdir -p /usr/local/etc;
|
||||
|
||||
$SUDO_CMD mv /tmp/$DISCOVERY_CONFIG_FILENAME /usr/local/etc/$DISCOVERY_CONFIG_FILENAME
|
||||
|
||||
{
|
||||
cat $PWD/.init_services;
|
||||
cat $DEST_FILE;
|
||||
} > /tmp/$DEST_FILE
|
||||
|
||||
$SUDO_CMD mv /tmp/$DEST_FILE /usr/local/etc/$DEST_FILE
|
||||
|
||||
|
||||
if [ "$DEBIAN" == "true" ] ; then
|
||||
{
|
||||
echo "
|
||||
[Unit]
|
||||
Description=Discover services
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/service-files.sh /usr/local/etc/results.txt restart
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
";
|
||||
|
||||
} > /tmp/discovery.service
|
||||
$SUDO_CMD mv /tmp/discovery.service /etc/systemd/system/discovery.service
|
||||
$SUDO_CMD systemctl enable discovery.service
|
||||
|
||||
elif [ "$GENTOO" == "true" ] ; then
|
||||
$SUDO_CMD echo "/usr/local/bin/service-files.sh /usr/local/etc/results.txt restart" > /etc/local.d/service-file.start;
|
||||
$SUDO_CMD chmod a+x /etc/local.d/service-file.start;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
rm $PWD/.init_services
|
||||
|
52
scan.php
52
scan.php
@@ -1,9 +1,53 @@
|
||||
<?php
|
||||
|
||||
include "functions.php";
|
||||
sleep(1);
|
||||
switch ($_GET["op"]) {
|
||||
"redis":
|
||||
echo ping_redis();
|
||||
"docker":
|
||||
case "redis":
|
||||
try {
|
||||
$ret = ping_redis();
|
||||
if ($ret===false) {
|
||||
echo "Can't ping redis-server";
|
||||
}
|
||||
else echo "OK";
|
||||
} catch (RedisException $e) {
|
||||
echo "RedisException caught: " . $e->getMessage();
|
||||
}
|
||||
break;
|
||||
case "init":
|
||||
$arr = array("STATUS" => 0);
|
||||
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
|
||||
|
||||
$op = "init:".date("YmdHis");
|
||||
redis_set($op,$json);
|
||||
echo "OK"; // TODO?
|
||||
break;
|
||||
case "check_init":
|
||||
$arr = check_redis("web_out");
|
||||
if (!empty($arr)) {
|
||||
foreach ($arr as $key=>$data) {
|
||||
if ($data["INSTALL_STATUS"]==2) echo "NEW";
|
||||
elseif ($data["INSTALL_STATUS"]==1) echo "EXISTS";
|
||||
redis_remove("$key");
|
||||
}
|
||||
}
|
||||
else echo "WAIT";
|
||||
break;
|
||||
case "check_install":
|
||||
$arr = check_redis("web_out",$_GET["key"]);
|
||||
if (!empty($arr)) {
|
||||
foreach ($arr as $key=>$data) {
|
||||
//echo $key."-".$_GET["key"];
|
||||
if ($key==$_GET["key"]) { // if install key moved to web_out
|
||||
if ($data["INSTALL_STATUS"]==1) {
|
||||
redis_remove("$key");
|
||||
echo "INSTALLED";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else echo "NOT EXISTS";
|
||||
break;
|
||||
case "docker":
|
||||
echo true;
|
||||
break;
|
||||
|
||||
|
@@ -20,6 +20,9 @@ a {
|
||||
font-size:9pt;
|
||||
font-family:Verdana;
|
||||
}
|
||||
div#output {
|
||||
text-align:left;
|
||||
}
|
||||
</STYLE>
|
||||
<SCRIPT LANGUAGE=VBScript>
|
||||
Set objNetwork = CreateObject("Wscript.Network")
|
||||
@@ -28,8 +31,8 @@ Set objShell = CreateObject("WScript.Shell")
|
||||
|
||||
Sub Window_OnLoad
|
||||
Dim X, Y, strComputer, objWMIService, colItems, objItem, intHorizontal, strYear, wcRegPath
|
||||
X=500
|
||||
Y=420
|
||||
X=1024
|
||||
Y=768
|
||||
window.resizeTo X,Y
|
||||
' resize the HTA
|
||||
strComputer = "."
|
||||
@@ -42,7 +45,7 @@ Sub Window_OnLoad
|
||||
window.moveTo (intHorizontal - X) / 2, (intVertical - Y) / 2
|
||||
' centre it
|
||||
'txtName.value=objNetwork.UserName
|
||||
txtHost.focus
|
||||
txtPort.focus
|
||||
|
||||
wcRegPath = "HKLM\SYSTEM\CurrentControlSet\Services\WebClient\Parameters\"
|
||||
|
||||
@@ -55,31 +58,220 @@ Sub Window_OnLoad
|
||||
'WriteToRegistry wcRegPath & "ServerNotFoundCacheLifeTimeInSec", 0, "REG_DWORD"
|
||||
'WriteToRegistry wcRegPath & "SupportLocking", 1, "REG_DWORD"
|
||||
|
||||
Dim dockerIsRunning
|
||||
dockerIsRunning = CheckDockerStatus()
|
||||
|
||||
If dockerIsRunning Then
|
||||
MsgBox "Docker is running in WSL.", vbInformation, "Docker Status"
|
||||
Else
|
||||
MsgBox "Docker is NOT running in WSL. Starting docker...", vbExclamation, "Docker Status"
|
||||
WSL = "wsl.exe --user root --exec /etc/init.d/docker start"
|
||||
intReturn = objShell.Run(WSL, 0, True)
|
||||
If Err.Number <> 0 Then
|
||||
MsgBox (Err.number & "-" & err.Description)
|
||||
else
|
||||
dockerIsRunning = CheckDockerStatus()
|
||||
If dockerIsRunning Then
|
||||
MsgBox "Docker is running in WSL. ", vbInformation, "Docker Status"
|
||||
Else
|
||||
MsgBox "ERROR: Starting Docker failed in WSL. Exiting install...", vbInformation, "Docker Status"
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub btnConfigure_OnClick
|
||||
Function CheckDockerStatus()
|
||||
|
||||
StartWSL
|
||||
Dim objExec, outputLine, allOutput
|
||||
|
||||
If txtHost.value="" Then
|
||||
MsgBox "Please enter hostname",16,"ERROR"
|
||||
txtHost.focus
|
||||
Exit Sub
|
||||
' WSL command to check Docker status
|
||||
Dim WSLCommand
|
||||
WSLCommand = "wsl.exe --user root --exec sh -c ""docker info | grep 'Server Version'"""
|
||||
|
||||
' Execute the command
|
||||
On Error Resume Next
|
||||
Set objExec = objShell.Exec(WSLCommand)
|
||||
|
||||
allOutput = ""
|
||||
|
||||
' Loop through the command's output
|
||||
Do While Not objExec.StdOut.AtEndOfStream
|
||||
outputLine = objExec.StdOut.ReadLine()
|
||||
allOutput = allOutput & outputLine & vbCrLf
|
||||
Loop
|
||||
|
||||
logToFile(allOutput)
|
||||
|
||||
' Check if the output contains 'Server Version'
|
||||
If InStr(allOutput, "Server Version") > 0 Then
|
||||
CheckDockerStatus = True
|
||||
Else
|
||||
CheckDockerStatus = False
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Function CheckScheduler()
|
||||
|
||||
Dim objExec, outputLine, allOutput
|
||||
|
||||
' WSL command to check Docker status
|
||||
Dim WSLCommand
|
||||
WSLCommand = "wsl.exe --user root --exec sh -c ""docker ps --format 'table {{.Names}}' | grep framework-scheduler"" "
|
||||
|
||||
' Execute the command
|
||||
On Error Resume Next
|
||||
Set objExec = objShell.Exec(WSLCommand)
|
||||
|
||||
allOutput = ""
|
||||
|
||||
' Loop through the command's output
|
||||
Do While Not objExec.StdOut.AtEndOfStream
|
||||
outputLine = objExec.StdOut.ReadLine()
|
||||
allOutput = allOutput & outputLine & vbCrLf
|
||||
Loop
|
||||
|
||||
logToFile(allOutput)
|
||||
|
||||
' Check if the output contains 'Server Version'
|
||||
If InStr(allOutput, "framework-scheduler") > 0 Then
|
||||
CheckScheduler = True
|
||||
Else
|
||||
CheckScheduler = False
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Sub logToFile(output)
|
||||
|
||||
' Log the output to a file (optional for debugging)
|
||||
Dim fso, logFile
|
||||
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||
Set logFile = fso.OpenTextFile("windows-installer.log", 2, True)
|
||||
logFile.WriteLine "Docker Command Output:" & vbCrLf & output
|
||||
logFile.Close
|
||||
End Sub
|
||||
|
||||
Sub btnStart_OnClick
|
||||
|
||||
'If txtHost.value="" Then
|
||||
' MsgBox "Please enter hostname",16,"ERROR"
|
||||
' txtHost.focus
|
||||
' Exit Sub
|
||||
'End If
|
||||
|
||||
If txtPort.value="" Then
|
||||
MsgBox "Please enter port number",16,"ERROR"
|
||||
MsgBox "Please enter webserver port number",16,"ERROR"
|
||||
txtPort.focus
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
MsgBox "TEST STARTED",64,"DONE"
|
||||
StartInstall
|
||||
|
||||
End Sub
|
||||
|
||||
Sub StartWSL()
|
||||
Sub btnOpen_OnClick
|
||||
|
||||
WSL = "wsl.exe --user root --exec docker ps > C:\Users\wslresult.txt"
|
||||
MsgBox "Open",64,"DONE"
|
||||
End Sub
|
||||
|
||||
Sub ShowOutput(objExec)
|
||||
|
||||
exitCode = objExec.ExitCode
|
||||
If exitCode = 0 Then
|
||||
' Read the output line by line
|
||||
outputLine = ""
|
||||
Do While Not objExec.StdOut.AtEndOfStream
|
||||
outputLine = outputLine & objExec.StdOut.ReadLine() & vbCrLf
|
||||
Loop
|
||||
|
||||
'WScript.Echo "Command executed successfully:" & vbCrLf & outputLine
|
||||
|
||||
logToFile(outputLine)
|
||||
Else
|
||||
Dim errorLine
|
||||
errorLine = ""
|
||||
Do While Not objExec.StdErr.AtEndOfStream
|
||||
errorLine = errorLine & objExec.StdErr.ReadLine() & vbCrLf
|
||||
Loop
|
||||
|
||||
'WScript.Echo "Command failed with exit code: " & exitCode & vbCrLf & "Error Output:" & vbCrLf & errorLine
|
||||
|
||||
logToFile(errorLine)
|
||||
End If
|
||||
|
||||
|
||||
' Call JS function to display output because Echo doesn't work in hta
|
||||
Call UpdateOutput(outputLine, errorLine)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Delay(seconds)
|
||||
' Simulate a delay by using a busy loop for the specified seconds
|
||||
Dim start, now
|
||||
start = Timer
|
||||
|
||||
Do
|
||||
now = Timer
|
||||
' Loop until the specified number of seconds has passed
|
||||
If now - start >= seconds Then Exit Do
|
||||
' Reset start if midnight is crossed
|
||||
If now < start Then start = now
|
||||
Loop
|
||||
End Sub
|
||||
|
||||
Sub StartInstall()
|
||||
|
||||
Dim WSL
|
||||
|
||||
'WSL = "wsl.exe --user root --exec docker ps > C:\Users\wslresult.txt"
|
||||
'intReturn = objShell.Run(WSL, 0, True)
|
||||
|
||||
Dim schedulerIsRunning
|
||||
schedulerIsRunning = CheckScheduler()
|
||||
|
||||
If schedulerIsRunning Then
|
||||
MsgBox "Scheduler is already running", vbInformation, "Docker Status"
|
||||
|
||||
WSL = "wsl.exe --user root --exec docker ps --format ""table {{.Names}}\t{{.Status}}"" "
|
||||
Set objExec = objShell.Exec(WSL)
|
||||
|
||||
ShowOutput(objExec)
|
||||
Else
|
||||
MsgBox "Scheduler is not running", vbInformation, "Docker Status"
|
||||
StartScheduler
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub StartScheduler()
|
||||
|
||||
WSL = "wsl.exe --user root --exec docker run -d -v /var/run/docker.sock:/var/run/docker.sock --env WEBSERVER_PORT=" & txtPort.value & " registry.format.hu/framework-scheduler"
|
||||
intReturn = objShell.Run(WSL, 0, True)
|
||||
|
||||
If Err.Number <> 0 Then
|
||||
MsgBox (Err.number & "-" & err.Description)
|
||||
else
|
||||
MsgBox "Framework scheduler is starting..."
|
||||
Delay 10
|
||||
WSL = "wsl.exe --user root --exec docker logs framework-scheduler"
|
||||
Set objExec = objShell.Exec(WSL)
|
||||
ShowOutput(objExec)
|
||||
|
||||
iterationCount = 0
|
||||
maxIterations = 12 ' Run for 1 minute (12 iterations of 5 seconds each)
|
||||
|
||||
'Do
|
||||
'iterationCount = iterationCount + 1
|
||||
'Set objExec = objShell.Exec(WSL)
|
||||
'ShowOutput(objExec)
|
||||
'Delay 5
|
||||
'If iterationCount >= maxIterations Then
|
||||
' MsgBox "Max iterations reached, stopping script."
|
||||
' Exit Do
|
||||
'End If
|
||||
'Loop
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub MapDrive(DriveLetter,DrivePath)
|
||||
@@ -173,19 +365,34 @@ Sub InstallCert(CertPath)
|
||||
End Sub
|
||||
|
||||
</SCRIPT>
|
||||
<script language="JavaScript">
|
||||
function UpdateOutput(output, errorOutput) {
|
||||
var outputElement = document.getElementById('output');
|
||||
|
||||
if (output !== '') {
|
||||
outputElement.innerText = output;
|
||||
} else if (errorOutput !== '') {
|
||||
outputElement.innerText = errorOutput;
|
||||
} else {
|
||||
outputElement.innerText = '...';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<tr>
|
||||
<td>host</td>
|
||||
<td><input type="text" name="txtHost" value="localhost"/></td>
|
||||
<td>Hostname:</td>
|
||||
<td><input type="text" name="txtHost" value="localhost" disabled="disabled"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>port</td>
|
||||
<td><input type="text" name="txtPort" value="80" maxlength="5" size="6" /></td>
|
||||
<td>Webserver port:</td>
|
||||
<td><input type="text" name="txtPort" value="8080" maxlength="5" size="6" /></td>
|
||||
</tr>
|
||||
<tr><td> </td><td> </td></tr>
|
||||
<tr><td> </td><td><input type="button" value="START" id=btnConfigure /></td></tr>
|
||||
<tr><td> </td><td><input type="button" value="START INSTALL" id=btnStart /></td></tr>
|
||||
</table>
|
||||
<br><br>
|
||||
<div id="output"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user