Skip to content
Snippets Groups Projects
Commit a0695d96 authored by Bob Mottram's avatar Bob Mottram
Browse files

Don't continue installing if no domain is provided

parent 6a87d72e
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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}"
......
......@@ -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";
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment