Template for apps without a web ui
This commit is contained in:
parent
fb0aa4fba2
commit
f5825cc2d6
|
@ -1,12 +1,10 @@
|
|||
#!/bin/bash
|
||||
# _____ _ _
|
||||
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
|
||||
# | __| _| -_| -_| . | . | | . | . | | -_|
|
||||
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
|
||||
#
|
||||
# .---. . .
|
||||
# | | |
|
||||
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
||||
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
||||
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
||||
#
|
||||
# Freedom in the Cloud
|
||||
# Freedom in the Cloud
|
||||
#
|
||||
# Command to create app templates
|
||||
#
|
||||
|
@ -43,6 +41,7 @@ app_port=
|
|||
app_port_internal=
|
||||
app_daemon=
|
||||
app_dir=
|
||||
app_webui=1
|
||||
your_name=''
|
||||
your_email=''
|
||||
SHOW_ON_ABOUT=1
|
||||
|
@ -68,6 +67,7 @@ function show_help {
|
|||
echo $' -p --php [yes|no] Is this a PHP app?'
|
||||
echo $' -s --daemon [yes|no] Add a daemon'
|
||||
echo $' -d --database [mariadb|postgresql] Type of database'
|
||||
echo $' -w --web [yes|no] Whether there is a web user interface (default is yes)'
|
||||
echo $' --dir [directory] Where to install to'
|
||||
echo ''
|
||||
exit 0
|
||||
|
@ -128,6 +128,12 @@ do
|
|||
app_onion_only=1
|
||||
fi
|
||||
;;
|
||||
-w|--web)
|
||||
shift
|
||||
if [[ "$1" == $'n'* || "$1" == $'N'* ]]; then
|
||||
app_webui=
|
||||
fi
|
||||
;;
|
||||
--port)
|
||||
shift
|
||||
app_port="$1"
|
||||
|
@ -187,15 +193,21 @@ if [[ "$your_email" != *'@'* ]]; then
|
|||
exit 8
|
||||
fi
|
||||
|
||||
if [ ! $app_webui ]; then
|
||||
if [ ! "$app_dir" ]; then
|
||||
app_dir=/etc/${app_name}
|
||||
fi
|
||||
app_php=
|
||||
fi
|
||||
|
||||
echo '#!/bin/bash'
|
||||
echo '#'
|
||||
echo '# .---. . .'
|
||||
echo '# | | |'
|
||||
echo '# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.'
|
||||
echo "# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'"
|
||||
echo "# ' ' --' --' -' - -' ' ' -' -' -' ' - --'"
|
||||
echo '# _____ _ _'
|
||||
echo '# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___'
|
||||
echo '# | __| _| -_| -_| . | . | | . | . | | -_|'
|
||||
echo '# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|'
|
||||
echo '#'
|
||||
echo '# Freedom in the Cloud'
|
||||
echo '# Freedom in the Cloud'
|
||||
echo '#'
|
||||
echo '# License'
|
||||
echo '# ======='
|
||||
|
@ -598,10 +610,13 @@ echo " if [ ! \"\$${app_name_upper}_DOMAIN_NAME\" ]; then"
|
|||
echo " echo \$'No domain name was given'"
|
||||
echo ' exit 3568356'
|
||||
echo ' fi'
|
||||
echo ''
|
||||
echo " if [ -d \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\" ]; then"
|
||||
echo " rm -rf \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
|
||||
echo ' fi'
|
||||
|
||||
if [ $app_webui ]; then
|
||||
echo ''
|
||||
echo " if [ -d \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\" ]; then"
|
||||
echo " rm -rf \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
|
||||
echo ' fi'
|
||||
fi
|
||||
|
||||
echo " if [ -d /repos/${app_name} ]; then"
|
||||
echo " mkdir \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
|
||||
|
@ -649,114 +664,118 @@ echo ''
|
|||
echo " add_ddns_domain \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
echo ''
|
||||
echo " ${app_name_upper}_ONION_HOSTNAME=\$(add_onion_service ${app_name} 80 \${${app_name_upper}_ONION_PORT})"
|
||||
echo ''
|
||||
echo " ${app_name}_nginx_site=/etc/nginx/sites-available/\$${app_name_upper}_DOMAIN_NAME"
|
||||
|
||||
if [ ! $app_onion_only ]; then
|
||||
echo " if [[ \"\$ONION_ONLY\" == \"no\" ]]; then"
|
||||
if [[ "$app_php" == 'yes' ]]; then
|
||||
echo " nginx_http_redirect \"\$${app_name_upper}_DOMAIN_NAME\" \"index index.php\""
|
||||
else
|
||||
echo " nginx_http_redirect \"\$${app_name_upper}_DOMAIN_NAME\" \"index index.html\""
|
||||
fi
|
||||
echo " { echo 'server {';"
|
||||
echo " echo ' listen 443 ssl;';"
|
||||
echo " echo ' #listen [::]:443 ssl;';"
|
||||
echo " echo \" server_name \$${app_name_upper}_DOMAIN_NAME;\";"
|
||||
echo " echo ''; } >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_compress \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
echo " echo '' >> \"\$${app_name}_nginx_site\""
|
||||
echo " echo ' # Security' >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_ssl \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
if [ $app_webui ]; then
|
||||
echo ''
|
||||
echo " nginx_security_options \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
echo ''
|
||||
echo " { echo ' add_header Strict-Transport-Security max-age=15768000;';"
|
||||
echo " echo '';"
|
||||
echo " echo ' # Logs';"
|
||||
echo " echo ' access_log /dev/null;';"
|
||||
echo " echo ' error_log /dev/null;';"
|
||||
echo " echo '';"
|
||||
echo " echo ' # Root';"
|
||||
echo " echo \" root /var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs;\";"
|
||||
echo " echo '';"
|
||||
if [[ "$app_php" == 'yes' ]]; then
|
||||
echo " echo ' index index.php;';"
|
||||
echo " echo ' location ~ \\.php {';"
|
||||
echo " echo ' include snippets/fastcgi-php.conf;';"
|
||||
echo " echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';"
|
||||
echo " echo ' fastcgi_read_timeout 30;';"
|
||||
echo " echo ' fastcgi_param HTTPS on;';"
|
||||
echo " echo ' }';"
|
||||
echo " ${app_name}_nginx_site=/etc/nginx/sites-available/\$${app_name_upper}_DOMAIN_NAME"
|
||||
|
||||
if [ ! $app_onion_only ]; then
|
||||
echo " if [[ \"\$ONION_ONLY\" == \"no\" ]]; then"
|
||||
if [[ "$app_php" == 'yes' ]]; then
|
||||
echo " nginx_http_redirect \"\$${app_name_upper}_DOMAIN_NAME\" \"index index.php\""
|
||||
else
|
||||
echo " nginx_http_redirect \"\$${app_name_upper}_DOMAIN_NAME\" \"index index.html\""
|
||||
fi
|
||||
echo " { echo 'server {';"
|
||||
echo " echo ' listen 443 ssl;';"
|
||||
echo " echo ' #listen [::]:443 ssl;';"
|
||||
echo " echo \" server_name \$${app_name_upper}_DOMAIN_NAME;\";"
|
||||
echo " echo ''; } >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_compress \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
echo " echo '' >> \"\$${app_name}_nginx_site\""
|
||||
echo " echo ' # Security' >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_ssl \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
echo ''
|
||||
echo " nginx_security_options \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
echo ''
|
||||
echo " { echo ' add_header Strict-Transport-Security max-age=15768000;';"
|
||||
echo " echo '';"
|
||||
echo " echo ' # Logs';"
|
||||
echo " echo ' access_log /dev/null;';"
|
||||
echo " echo ' error_log /dev/null;';"
|
||||
echo " echo '';"
|
||||
echo " echo ' # Root';"
|
||||
echo " echo \" root /var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs;\";"
|
||||
echo " echo '';"
|
||||
if [[ "$app_php" == 'yes' ]]; then
|
||||
echo " echo ' index index.php;';"
|
||||
echo " echo ' location ~ \\.php {';"
|
||||
echo " echo ' include snippets/fastcgi-php.conf;';"
|
||||
echo " echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';"
|
||||
echo " echo ' fastcgi_read_timeout 30;';"
|
||||
echo " echo ' fastcgi_param HTTPS on;';"
|
||||
echo " echo ' }';"
|
||||
echo " echo '';"
|
||||
else
|
||||
echo " echo ' index index.html;';"
|
||||
fi
|
||||
echo " echo ' # Location';"
|
||||
echo " echo ' location / {'; } >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_limits \"\$${app_name_upper}_DOMAIN_NAME\" '15m'"
|
||||
if [ ! $app_daemon ]; then
|
||||
if [[ "$app_php" != 'yes' ]]; then
|
||||
echo " { echo \" try_files \\\$uri \\\$uri/ /index.html;\";"
|
||||
else
|
||||
echo " { echo \" try_files \\\$uri \\\$uri/ /index.php?\\\$args;\";"
|
||||
fi
|
||||
else
|
||||
echo " { echo \" proxy_pass http://localhost:\$${app_name_upper}_PORT_INTERNAL;\";"
|
||||
fi
|
||||
echo " echo ' }';"
|
||||
echo " echo '}'; } >> \"\$${app_name}_nginx_site\""
|
||||
echo ' else'
|
||||
echo " echo -n '' > \"\$${app_name}_nginx_site\""
|
||||
echo ' fi'
|
||||
else
|
||||
echo " echo -n '' > \"\$${app_name}_nginx_site\""
|
||||
fi
|
||||
echo " { echo 'server {';"
|
||||
echo " echo \" listen 127.0.0.1:\$${app_name_upper}_ONION_PORT default_server;\";"
|
||||
echo " echo \" server_name \$${app_name_upper}_ONION_HOSTNAME;\";"
|
||||
echo " echo ''; } >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_compress \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
echo " echo '' >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_security_options \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
echo " { echo '';"
|
||||
echo " echo ' # Logs';"
|
||||
echo " echo ' access_log /dev/null;';"
|
||||
echo " echo ' error_log /dev/null;';"
|
||||
echo " echo '';"
|
||||
echo " echo ' # Root';"
|
||||
echo " echo \" root /var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs;\";"
|
||||
echo " echo '';"
|
||||
if [[ "$app_php" == 'yes' ]]; then
|
||||
echo " echo ' index index.php;';"
|
||||
echo " echo ' location ~ \\.php {';"
|
||||
echo " echo ' include snippets/fastcgi-php.conf;';"
|
||||
echo " echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';"
|
||||
echo " echo ' fastcgi_read_timeout 30;';"
|
||||
echo " echo ' fastcgi_param HTTPS off;';"
|
||||
echo " echo ' }';"
|
||||
echo " echo '';"
|
||||
else
|
||||
echo " echo ' index index.html;';"
|
||||
fi
|
||||
echo " echo ' # Location';"
|
||||
echo " echo ' location / {'; } >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_limits \"\$${app_name_upper}_DOMAIN_NAME\" '15m'"
|
||||
echo " echo ' # Location';"
|
||||
echo " echo ' location / {'; } >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_limits \"\$${app_name_upper}_DOMAIN_NAME\" '15m'"
|
||||
if [ ! $app_daemon ]; then
|
||||
if [[ "$app_php" != 'yes' ]]; then
|
||||
echo " { echo \" try_files \\\$uri \\\$uri/ /index.html;\";"
|
||||
echo " { echo \" try_files \\\$uri \\\$uri/ index.html;\";"
|
||||
else
|
||||
echo " { echo \" try_files \\\$uri \\\$uri/ /index.php?\\\$args;\";"
|
||||
echo " { echo \" try_files \\\$uri \\\$uri/ index.php?\\\$args;\";"
|
||||
fi
|
||||
else
|
||||
echo " { echo \" proxy_pass http://localhost:\$${app_name_upper}_PORT_INTERNAL;\";"
|
||||
echo " echo \" proxy_pass http://localhost:\$${app_name_upper}_PORT_INTERNAL;\";"
|
||||
fi
|
||||
echo " echo ' }';"
|
||||
echo " echo '}'; } >> \"\$${app_name}_nginx_site\""
|
||||
echo ' else'
|
||||
echo " echo -n '' > \"\$${app_name}_nginx_site\""
|
||||
echo ' fi'
|
||||
else
|
||||
echo " echo -n '' > \"\$${app_name}_nginx_site\""
|
||||
fi
|
||||
echo " { echo 'server {';"
|
||||
echo " echo \" listen 127.0.0.1:\$${app_name_upper}_ONION_PORT default_server;\";"
|
||||
echo " echo \" server_name \$${app_name_upper}_ONION_HOSTNAME;\";"
|
||||
echo " echo ''; } >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_compress \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
echo " echo '' >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_security_options \"\$${app_name_upper}_DOMAIN_NAME\""
|
||||
echo " { echo '';"
|
||||
echo " echo ' # Logs';"
|
||||
echo " echo ' access_log /dev/null;';"
|
||||
echo " echo ' error_log /dev/null;';"
|
||||
echo " echo '';"
|
||||
echo " echo ' # Root';"
|
||||
echo " echo \" root /var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs;\";"
|
||||
echo " echo '';"
|
||||
if [[ "$app_php" == 'yes' ]]; then
|
||||
echo " echo ' index index.php;';"
|
||||
echo " echo ' location ~ \\.php {';"
|
||||
echo " echo ' include snippets/fastcgi-php.conf;';"
|
||||
echo " echo ' fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;';"
|
||||
echo " echo ' fastcgi_read_timeout 30;';"
|
||||
echo " echo ' fastcgi_param HTTPS off;';"
|
||||
echo " echo ' }';"
|
||||
echo " echo '';"
|
||||
else
|
||||
echo " echo ' index index.html;';"
|
||||
fi
|
||||
echo " echo ' # Location';"
|
||||
echo " echo ' location / {'; } >> \"\$${app_name}_nginx_site\""
|
||||
echo " nginx_limits \"\$${app_name_upper}_DOMAIN_NAME\" '15m'"
|
||||
if [ ! $app_daemon ]; then
|
||||
if [[ "$app_php" != 'yes' ]]; then
|
||||
echo " { echo \" try_files \\\$uri \\\$uri/ index.html;\";"
|
||||
else
|
||||
echo " { echo \" try_files \\\$uri \\\$uri/ index.php?\\\$args;\";"
|
||||
echo " echo '}'; } >> \"\$${app_name}_nginx_site\""
|
||||
if [[ "$app_php" == 'yes' ]]; then
|
||||
echo ''
|
||||
echo ' configure_php'
|
||||
fi
|
||||
else
|
||||
echo " echo \" proxy_pass http://localhost:\$${app_name_upper}_PORT_INTERNAL;\";"
|
||||
fi
|
||||
echo " echo ' }';"
|
||||
echo " echo '}'; } >> \"\$${app_name}_nginx_site\""
|
||||
if [[ "$app_php" == 'yes' ]]; then
|
||||
echo ''
|
||||
echo ' configure_php'
|
||||
fi
|
||||
|
||||
if [ $app_daemon ]; then
|
||||
echo ''
|
||||
echo " useradd -d \"TODO_PATH_TO_INSTALL\" -s /bin/false ${app_name}"
|
||||
|
|
Loading…
Reference in New Issue