Template changed for handling no web UI apps

This commit is contained in:
Bob Mottram 2018-04-08 15:56:54 +01:00
parent 466b5c023e
commit 2f379cdb67
1 changed files with 143 additions and 101 deletions

View File

@ -291,6 +291,7 @@ echo '}'
echo '' echo ''
echo "function install_interactive_${app_name} {" echo "function install_interactive_${app_name} {"
if [ ! $app_onion_only ]; then if [ ! $app_onion_only ]; then
if [ $app_webui ]; then
echo " if [ ! \"\$ONION_ONLY\" ]; then" echo " if [ ! \"\$ONION_ONLY\" ]; then"
echo " ONION_ONLY='no'" echo " ONION_ONLY='no'"
echo ' fi' echo ' fi'
@ -304,14 +305,19 @@ if [ ! $app_onion_only ]; then
else else
echo " echo -n ''" echo " echo -n ''"
fi fi
else
echo " echo -n ''"
fi
echo ' APP_INSTALLED=1' echo ' APP_INSTALLED=1'
echo '}' echo '}'
echo '' echo ''
echo "function change_password_${app_name} {" echo "function change_password_${app_name} {"
echo " curr_username=\"\$1\"" echo " curr_username=\"\$1\""
echo " new_user_password=\"\$2\"" echo " new_user_password=\"\$2\""
if [ $app_webui ]; then
echo '' echo ''
echo " read_config_param '${app_name_upper}_DOMAIN_NAME'" echo " read_config_param '${app_name_upper}_DOMAIN_NAME'"
fi
echo '' echo ''
echo " \"\${PROJECT_NAME}-pass\" -u \"\$curr_username\" -a ${app_name} -p \"\$new_user_password\"" echo " \"\${PROJECT_NAME}-pass\" -u \"\$curr_username\" -a ${app_name} -p \"\$new_user_password\""
echo '}' echo '}'
@ -381,10 +387,12 @@ echo " CURR_${app_name_upper}_COMMIT=\$(get_completion_param \"${app_name} co
echo " if [[ \"\$CURR_${app_name_upper}_COMMIT\" == \"\$${app_name_upper}_COMMIT\" ]]; then" echo " if [[ \"\$CURR_${app_name_upper}_COMMIT\" == \"\$${app_name_upper}_COMMIT\" ]]; then"
echo ' return' echo ' return'
echo ' fi' echo ' fi'
if [ $app_webui ]; then
echo '' echo ''
echo " if grep -q \"${app_name} domain\" \"\$COMPLETION_FILE\"; then" echo " if grep -q \"${app_name} domain\" \"\$COMPLETION_FILE\"; then"
echo " ${app_name_upper}_DOMAIN_NAME=\$(get_completion_param \"${app_name} domain\")" echo " ${app_name_upper}_DOMAIN_NAME=\$(get_completion_param \"${app_name} domain\")"
echo ' fi' echo ' fi'
fi
echo '' echo ''
echo ' # update to the next commit' echo ' # update to the next commit'
if [ ! "$app_dir" ]; then if [ ! "$app_dir" ]; then
@ -407,8 +415,10 @@ if [ ! "$app_dir" ]; then
else else
echo " source_directory=${app_dir}" echo " source_directory=${app_dir}"
fi fi
if [ $app_webui ]; then
echo '' echo ''
echo " suspend_site \"\${${app_name_upper}_DOMAIN_NAME}\"" echo " suspend_site \"\${${app_name_upper}_DOMAIN_NAME}\""
fi
echo '' echo ''
echo " dest_directory=${app_name}" echo " dest_directory=${app_name}"
echo " backup_directory_to_usb \"\$source_directory\" \$dest_directory" echo " backup_directory_to_usb \"\$source_directory\" \$dest_directory"
@ -422,15 +432,21 @@ if [[ "$database_type" == "postgres"* ]]; then
echo " backup_database_to_usb ${app_name}" echo " backup_database_to_usb ${app_name}"
echo '' echo ''
fi fi
if [ $app_webui ]; then
echo ' restart_site' echo ' restart_site'
fi
echo '}' echo '}'
echo '' echo ''
echo "function restore_local_${app_name} {" echo "function restore_local_${app_name} {"
echo " if ! grep -q \"${app_name} domain\" \"\$COMPLETION_FILE\"; then" echo " if ! grep -q \"${app_name} domain\" \"\$COMPLETION_FILE\"; then"
echo ' return' echo ' return'
echo ' fi' echo ' fi'
if [ $app_webui ]; then
echo " ${app_name_upper}_DOMAIN_NAME=\$(get_completion_param \"${app_name} domain\")" echo " ${app_name_upper}_DOMAIN_NAME=\$(get_completion_param \"${app_name} domain\")"
echo " if [ \"\$${app_name_upper}_DOMAIN_NAME\" ]; then" echo " if [ ! \"\$${app_name_upper}_DOMAIN_NAME\" ]; then"
echo " return"
echo " fi"
fi
echo " temp_restore_dir=/root/temp${app_name}" echo " temp_restore_dir=/root/temp${app_name}"
if [ ! "$app_dir" ]; then if [ ! "$app_dir" ]; then
echo " ${app_name}_dir=/var/www/\${${app_name_upper}_DOMAIN_NAME}/htdocs" echo " ${app_name}_dir=/var/www/\${${app_name_upper}_DOMAIN_NAME}/htdocs"
@ -467,11 +483,13 @@ echo " mkdir \"\$${app_name}_dir\""
echo ' fi' echo ' fi'
echo " cp -rp \"\$temp_restore_dir\"/* \"\$${app_name}_dir\"/" echo " cp -rp \"\$temp_restore_dir\"/* \"\$${app_name}_dir\"/"
echo ' fi' echo ' fi'
if [[ ! "$app_dir" ]]; then
echo " chown -R www-data:www-data \"\$${app_name}_dir\"" echo " chown -R www-data:www-data \"\$${app_name}_dir\""
else
echo " chown -R ${app_name}:${app_name} \"\$${app_name}_dir\""
fi
echo " rm -rf \$temp_restore_dir" echo " rm -rf \$temp_restore_dir"
echo ' fi' echo ' fi'
echo ''
echo ' fi'
echo '}' echo '}'
echo '' echo ''
echo "function backup_remote_${app_name} {" echo "function backup_remote_${app_name} {"
@ -485,8 +503,10 @@ if [ ! "$app_dir" ]; then
else else
echo " source_directory=${app_dir}" echo " source_directory=${app_dir}"
fi fi
if [ $app_webui ]; then
echo '' echo ''
echo " suspend_site \"\${${app_name_upper}_DOMAIN_NAME}\"" echo " suspend_site \"\${${app_name_upper}_DOMAIN_NAME}\""
fi
echo '' echo ''
echo " dest_directory=${app_name}" echo " dest_directory=${app_name}"
echo " backup_directory_to_friend \"\$source_directory\" \$dest_directory" echo " backup_directory_to_friend \"\$source_directory\" \$dest_directory"
@ -499,8 +519,10 @@ if [[ "$database_type" == "postgres"* ]]; then
echo " backup_database_to_friend ${app_name}" echo " backup_database_to_friend ${app_name}"
echo '' echo ''
fi fi
if [ $app_webui ]; then
echo '' echo ''
echo ' restart_site' echo ' restart_site'
fi
echo '}' echo '}'
echo '' echo ''
echo "function restore_remote_${app_name} {" echo "function restore_remote_${app_name} {"
@ -508,7 +530,9 @@ echo " if ! grep -q \"${app_name} domain\" \"\$COMPLETION_FILE\"; then"
echo ' return' echo ' return'
echo ' fi' echo ' fi'
echo " ${app_name_upper}_DOMAIN_NAME=\$(get_completion_param \"${app_name} domain\")" echo " ${app_name_upper}_DOMAIN_NAME=\$(get_completion_param \"${app_name} domain\")"
echo " if [ \"\$${app_name_upper}_DOMAIN_NAME\" ]; then" echo " if [ ! \"\$${app_name_upper}_DOMAIN_NAME\" ]; then"
echo " return"
echo " fi"
echo " temp_restore_dir=/root/temp${app_name}" echo " temp_restore_dir=/root/temp${app_name}"
if [ ! "$app_dir" ]; then if [ ! "$app_dir" ]; then
echo " ${app_name}_dir=/var/www/\${${app_name_upper}_DOMAIN_NAME}/htdocs" echo " ${app_name}_dir=/var/www/\${${app_name_upper}_DOMAIN_NAME}/htdocs"
@ -545,11 +569,13 @@ echo " mkdir \"\$${app_name}_dir\""
echo ' fi' echo ' fi'
echo " cp -rp \$temp_restore_dir/* \"\$${app_name}_dir\"/" echo " cp -rp \$temp_restore_dir/* \"\$${app_name}_dir\"/"
echo ' fi' echo ' fi'
if [[ ! "$app_dir" ]]; then
echo " chown -R www-data:www-data \"\$${app_name}_dir\"" echo " chown -R www-data:www-data \"\$${app_name}_dir\""
else
echo " chown -R ${app_name}:${app_name} \"\$${app_name}_dir\""
fi
echo " rm -rf \$temp_restore_dir" echo " rm -rf \$temp_restore_dir"
echo ' fi' echo ' fi'
echo ''
echo ' fi'
echo '}' echo '}'
echo '' echo ''
echo "function remove_${app_name} {" echo "function remove_${app_name} {"
@ -568,6 +594,7 @@ if [ $app_daemon ]; then
echo ' fi' echo ' fi'
echo " userdel -r ${app_name}" echo " userdel -r ${app_name}"
fi fi
if [ $app_webui ]; then
echo '' echo ''
echo " if [ -d \"/var/www/\$${app_name_upper}_DOMAIN_NAME\" ]; then" echo " if [ -d \"/var/www/\$${app_name_upper}_DOMAIN_NAME\" ]; then"
echo " rm -rf \"/var/www/\$${app_name_upper}_DOMAIN_NAME\"" echo " rm -rf \"/var/www/\$${app_name_upper}_DOMAIN_NAME\""
@ -575,6 +602,7 @@ echo ' fi'
echo " if [ -f \"/etc/nginx/sites-available/\$${app_name_upper}_DOMAIN_NAME\" ]; then" echo " if [ -f \"/etc/nginx/sites-available/\$${app_name_upper}_DOMAIN_NAME\" ]; then"
echo " rm \"/etc/nginx/sites-available/\$${app_name_upper}_DOMAIN_NAME\"" echo " rm \"/etc/nginx/sites-available/\$${app_name_upper}_DOMAIN_NAME\""
echo ' fi' echo ' fi'
fi
if [[ "$database_type" == "mariadb" || "$database_type" == "mysql" ]]; then if [[ "$database_type" == "mariadb" || "$database_type" == "mysql" ]]; then
echo " drop_database ${app_name}" echo " drop_database ${app_name}"
fi fi
@ -592,8 +620,10 @@ if [ "$app_port" ]; then
echo '' echo ''
echo " firewall_remove ${app_port} tcp" echo " firewall_remove ${app_port} tcp"
fi fi
if [ $app_webui ]; then
echo '' echo ''
echo " remove_ddns_domain \"\$${app_name_upper}_DOMAIN_NAME\"" echo " remove_ddns_domain \"\$${app_name_upper}_DOMAIN_NAME\""
fi
echo '}' echo '}'
echo '' echo ''
echo "function install_${app_name} {" echo "function install_${app_name} {"
@ -632,7 +662,9 @@ if [ $app_webui ]; then
fi fi
echo " if [ -d /repos/${app_name} ]; then" echo " if [ -d /repos/${app_name} ]; then"
if [ $app_webui ]; then
echo " mkdir \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\"" echo " mkdir \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
fi
if [ ! "$app_dir" ]; then if [ ! "$app_dir" ]; then
echo " cp -r -p /repos/${app_name}/. \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\"" echo " cp -r -p /repos/${app_name}/. \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
echo " cd \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\" || exit 324687356" echo " cd \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\" || exit 324687356"
@ -665,16 +697,20 @@ else
fi fi
echo " git checkout \$${app_name_upper}_COMMIT -b \$${app_name_upper}_COMMIT" echo " git checkout \$${app_name_upper}_COMMIT -b \$${app_name_upper}_COMMIT"
echo " set_completion_param \"${app_name} commit\" \"\$${app_name_upper}_COMMIT\"" echo " set_completion_param \"${app_name} commit\" \"\$${app_name_upper}_COMMIT\""
if [ $app_webui ]; then
echo '' echo ''
echo " chmod g+w \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\"" echo " chmod g+w \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
echo " chown -R www-data:www-data \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\"" echo " chown -R www-data:www-data \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
fi
if [[ "$database_type" == "mariadb" || "$database_type" == "mysql" || "$database_type" == "postgres"* ]]; then if [[ "$database_type" == "mariadb" || "$database_type" == "mysql" || "$database_type" == "postgres"* ]]; then
echo '' echo ''
echo " ${app_name}_create_database" echo " ${app_name}_create_database"
fi fi
if [ $app_webui ]; then
echo '' echo ''
echo " add_ddns_domain \"\$${app_name_upper}_DOMAIN_NAME\"" echo " add_ddns_domain \"\$${app_name_upper}_DOMAIN_NAME\""
fi
echo '' echo ''
echo " ${app_name_upper}_ONION_HOSTNAME=\$(add_onion_service ${app_name} 80 \${${app_name_upper}_ONION_PORT})" echo " ${app_name_upper}_ONION_HOSTNAME=\$(add_onion_service ${app_name} 80 \${${app_name_upper}_ONION_PORT})"
@ -819,18 +855,24 @@ if [ $app_daemon ]; then
fi fi
echo " systemctl start ${app_name}" echo " systemctl start ${app_name}"
fi fi
if [ $app_webui ]; then
echo '' echo ''
echo " create_site_certificate \"\$${app_name_upper}_DOMAIN_NAME\" 'yes'" echo " create_site_certificate \"\$${app_name_upper}_DOMAIN_NAME\" 'yes'"
echo '' echo ''
echo " nginx_ensite \"\$${app_name_upper}_DOMAIN_NAME\"" echo " nginx_ensite \"\$${app_name_upper}_DOMAIN_NAME\""
echo '' fi
if [[ "$database_type" == "mariadb" || "$database_type" == "mysql" ]]; then if [[ "$database_type" == "mariadb" || "$database_type" == "mysql" ]]; then
echo ''
echo ' systemctl restart mariadb' echo ' systemctl restart mariadb'
fi fi
if [ $app_webui ]; then
if [[ "$app_php" == 'yes' ]]; then if [[ "$app_php" == 'yes' ]]; then
echo ''
echo ' systemctl restart php7.0-fpm' echo ' systemctl restart php7.0-fpm'
fi fi
echo ''
echo ' systemctl restart nginx' echo ' systemctl restart nginx'
fi
echo '' echo ''
echo " \"\${PROJECT_NAME}-pass\" -u \"\$MY_USERNAME\" -a ${app_name} -p \"\$${app_name_upper}_ADMIN_PASSWORD\"" echo " \"\${PROJECT_NAME}-pass\" -u \"\$MY_USERNAME\" -a ${app_name} -p \"\$${app_name_upper}_ADMIN_PASSWORD\""
echo " set_completion_param \"${app_name} domain\" \"\$${app_name_upper}_DOMAIN_NAME\"" echo " set_completion_param \"${app_name} domain\" \"\$${app_name_upper}_DOMAIN_NAME\""