diff --git a/src/freedombone-installer b/src/freedombone-installer index fee63fd02a70572b956fdb332a0b85ddbca3ac06..8ac89cb535adc5951599b567bd9fd5688c36c7ec 100755 --- a/src/freedombone-installer +++ b/src/freedombone-installer @@ -46,11 +46,11 @@ do if [ -f "$pending_installs" ]; then linestr=$(head -n 1 "$pending_installs") if [[ "$linestr" == "install_"* ]]; then - app_name=$(echo "$linestr" | awk -F '_' '{print $2}' | awk -F ' ' '{print $1}') + app_name=$(echo "$linestr" | awk -F '_' '{print $2}' | awk -F ',' '{print $1}') if [ -f "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}" ]; then - app_domain=$(echo "$linestr" | awk -F ' ' '{print $2}') + app_domain=$(echo "$linestr" | awk -F ',' '{print $2}') app_name_upper=$(echo "$app_name" | awk '{print toupper($0)}') - freedns_code=$(echo "$linestr" | awk -F ' ' '{print $3}') + freedns_code=$(echo "$linestr" | awk -F ',' '{print $3}') # indicate that we are installing if [[ "$linestr" != *'_running'* ]]; then diff --git a/src/freedombone-utils-webadmin b/src/freedombone-utils-webadmin index 3733c57815f442dec3fdfe3346a3326645c61314..48009aaa8e95fd62ee443ad1b08edb0a35ec3a44 100755 --- a/src/freedombone-utils-webadmin +++ b/src/freedombone-utils-webadmin @@ -253,7 +253,9 @@ function web_admin_create_add_apps { # remove freedns if necessary if [[ "$DDNS_PROVIDER" != *"freedns"* ]]; then - sed -i '/freedns_code/d' "$filename" + if grep -q 'freedns_code' "$filename"; then + sed -i '/freedns_code/d' "$filename" + fi fi available_apps_ctr=$((available_apps_ctr+1)) @@ -429,6 +431,14 @@ function web_admin_get_language_subdir { echo "$lang_lower" | awk '{print toupper($0)}' } +function web_admin_onion_only { + # In onion only mode domain names or ddns codes + # don't need to be provided + sed -i '/freedns_code/d' "/var/www/${local_hostname}/htdocs/admin/app_add_template.html" + sed -i '/install_domain/d' "/var/www/${local_hostname}/htdocs/admin/app_add_template.html" + sed -i 's|onion_only=false;|onion_only=true;|g' "/var/www/${local_hostname}/htdocs/admin/installapp.php" +} + function install_web_admin { # This is intended as an admin web user interface # similar to Plinth or the yunohost @@ -446,6 +456,12 @@ function install_web_admin { if [ -d "/usr/share/${PROJECT_NAME}/webadmin/${language_subdir}" ]; then cp -r "/usr/share/${PROJECT_NAME}/webadmin"/* "/var/www/${local_hostname}/htdocs/admin" cp "/usr/share/${PROJECT_NAME}/webadmin/${language_subdir}"/*.html "/var/www/${local_hostname}/htdocs/admin" + + read_config_param ONION_ONLY + if [[ "$ONION_ONLY" != 'no' ]]; then + web_admin_onion_only + fi + web_admin_installed=1 else echo $"No web admin language subdirectory for ${language_subdir}" diff --git a/webadmin/installapp.php b/webadmin/installapp.php index 33ecc01e07ec549b03f4dceae320014b39acf36e..4b4e4065945ab73cec7d4b30ec9a88cb946eb2c2 100755 --- a/webadmin/installapp.php +++ b/webadmin/installapp.php @@ -4,20 +4,35 @@ $output_filename = "apps_add.html"; if (isset($_POST['install'])) { $app_name = htmlspecialchars($_POST['app_name']); - $install_domain = $_POST['install_domain']; - $freedns_code = $_POST['freedns_code']; + $install_domain = ''; + $freedns_code = ''; + + // Note that this value can be changed by install_web_admin + $onion_only=false; $continue_install=true; - if(file_exists("pending_removes.txt")) { - // Is this app in the pending_removes list? - if(exec('grep '.escapeshellarg("remove_".$app_name).' ./pending_removes.txt')) { - if(! exec('grep '.escapeshellarg("remove_".$app_name).'_running ./pending_removes.txt')) { - // Not Removing yet so remove from schedule - exec('sed -i "/'.escapeshellarg("remove_".$app_name).'/d'); - } - else { - // Removing so don't continue - $continue_install=false; + + if(! $onion_only) { + $install_domain = $_POST['install_domain']; + if (!strpos($install_domain, '.')) { + // No domain was provided + $continue_install=false; + } + $freedns_code = $_POST['freedns_code']; + } + + if($continue_install) { + if(file_exists("pending_removes.txt")) { + // Is this app in the pending_removes list? + if(exec('grep '.escapeshellarg("remove_".$app_name).' ./pending_removes.txt')) { + if(! exec('grep '.escapeshellarg("remove_".$app_name).'_running ./pending_removes.txt')) { + // Not Removing yet so remove from schedule + exec('sed -i "/'.escapeshellarg("remove_".$app_name).'/d ./pending_removes.txt'); + } + else { + // Removing so don't continue + $continue_install=false; + } } } } @@ -30,7 +45,7 @@ if (isset($_POST['install'])) { if(! exec('grep '.escapeshellarg("install_".$app_name).' ./pending_installs.txt')) { $pending_installs = fopen("pending_installs.txt", "a") or die("Unable to append to installs file"); - fwrite($pending_installs, "install_".$app_name." ".$install_domain." ".$freedns_code."\n"); + fwrite($pending_installs, "install_".$app_name.",".$install_domain.",".$freedns_code."\n"); fclose($pending_installs); $output_filename = "app_installing.html"; } diff --git a/webadmin/removeapp.php b/webadmin/removeapp.php index 61a068f99f9c985f398dc92aac717a31a2bbe451..bc1b5007865b07bab8d5d7475ed33566d07c2efa 100755 --- a/webadmin/removeapp.php +++ b/webadmin/removeapp.php @@ -11,7 +11,7 @@ if (isset($_POST['uninstall'])) { if(exec('grep '.escapeshellarg("install_".$app_name).' ./pending_installs.txt')) { if(! exec('grep '.escapeshellarg("install_".$app_name).'_running ./pending_installs.txt')) { // Not installing yet so remove from schedule - exec('sed -i "/'.escapeshellarg("install_".$app_name).'/d'); + exec('sed -i "/'.escapeshellarg("install_".$app_name).'/d ./pending_installs.txt'); } else { // Installing so don't continue