Browse Source

Specify internal port within template command

stretch
Bob Mottram 2 years ago
parent
commit
275b915d17
2 changed files with 73 additions and 53 deletions
  1. BIN
      man/freedombone-template.1.gz
  2. + 73
    - 53
      src/freedombone-template

BIN
man/freedombone-template.1.gz


+ 73
- 53
src/freedombone-template

@ -32,7 +32,7 @@ app_name='noapp'
app_name_lower=$(echo "${app_name}" | tr '[:upper:]' '[:lower:]')
app_name=$app_name_lower
app_name_upper=$(echo "${app_name}" | tr '[:lower:]' '[:upper:]')
app_repo="TODO"
app_repo=
app_repo_commit='TODO'
app_php=
app_node=
@ -75,6 +75,7 @@ function show_help {
echo $' -d --database [mariadb|postgresql|mongodb] 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 $' -i --internalport [number] Internal port number for the daemon'
echo ''
exit 0
}
@ -114,6 +115,10 @@ do
shift
database_type="$1"
;;
-i|--internal|--internalport)
shift
app_port_internal="$1"
;;
-p|--php)
shift
app_php="$1"
@ -263,8 +268,10 @@ if [ "$app_port" ]; then
echo "${app_name_upper}_PORT=$app_port"
fi
echo "${app_name_upper}_ONION_PORT=$(( ( RANDOM % 1000 ) + 9010 ))"
echo "${app_name_upper}_REPO=\"${app_repo}\""
echo "${app_name_upper}_COMMIT='${app_repo_commit}'"
if [ "$app_repo" ]; then
echo "${app_name_upper}_REPO=\"${app_repo}\""
echo "${app_name_upper}_COMMIT='${app_repo_commit}'"
fi
if [ $app_daemon ]; then
if [ ! "$app_port_internal" ]; then
echo "${app_name_upper}_PORT_INTERNAL=TODO"
@ -391,27 +398,31 @@ echo ' done'
echo '}'
echo ''
echo "function upgrade_${app_name} {"
echo " CURR_${app_name_upper}_COMMIT=\$(get_completion_param \"${app_name} commit\")"
echo " if [[ \"\$CURR_${app_name_upper}_COMMIT\" == \"\$${app_name_upper}_COMMIT\" ]]; then"
echo ' return'
echo ' fi'
if [ $app_webui ]; then
echo ''
echo " if grep -q \"${app_name} domain\" \"\$COMPLETION_FILE\"; then"
echo " ${app_name_upper}_DOMAIN_NAME=\$(get_completion_param \"${app_name} domain\")"
echo ' fi'
fi
echo ''
echo ' # update to the next commit'
if [ ! "$app_dir" ]; then
echo " set_repo_commit \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\" \"${app_name} commit\" \"\$${app_name_upper}_COMMIT\" \"\$${app_name_upper}_REPO\""
echo " chown -R www-data:www-data \"/var/www/\${${app_name_upper}_DOMAIN_NAME}/htdocs\""
if [ ! "$app_repo" ]; then
echo "echo -n ''"
else
echo " set_repo_commit \"${app_dir}\" \"${app_name} commit\" \"\$${app_name_upper}_COMMIT\" \"\$${app_name_upper}_REPO\""
echo " chown -R ${app_name}:${app_name} \"${app_dir}\""
fi
if [ $app_daemon ]; then
echo " systemctl restart ${app_name}"
echo " CURR_${app_name_upper}_COMMIT=\$(get_completion_param \"${app_name} commit\")"
echo " if [[ \"\$CURR_${app_name_upper}_COMMIT\" == \"\$${app_name_upper}_COMMIT\" ]]; then"
echo ' return'
echo ' fi'
if [ $app_webui ]; then
echo ''
echo " if grep -q \"${app_name} domain\" \"\$COMPLETION_FILE\"; then"
echo " ${app_name_upper}_DOMAIN_NAME=\$(get_completion_param \"${app_name} domain\")"
echo ' fi'
fi
echo ''
echo ' # update to the next commit'
if [ ! "$app_dir" ]; then
echo " set_repo_commit \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\" \"${app_name} commit\" \"\$${app_name_upper}_COMMIT\" \"\$${app_name_upper}_REPO\""
echo " chown -R www-data:www-data \"/var/www/\${${app_name_upper}_DOMAIN_NAME}/htdocs\""
else
echo " set_repo_commit \"${app_dir}\" \"${app_name} commit\" \"\$${app_name_upper}_COMMIT\" \"\$${app_name_upper}_REPO\""
echo " chown -R ${app_name}:${app_name} \"${app_dir}\""
fi
if [ $app_daemon ]; then
echo " systemctl restart ${app_name}"
fi
fi
echo '}'
echo ''
@ -775,42 +786,51 @@ if [ $app_webui ]; then
echo ' fi'
fi
echo " if [ -d /repos/${app_name} ]; then"
if [ $app_webui ]; then
echo " mkdir \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
fi
if [ ! "$app_dir" ]; then
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"
else
echo " cp -r -p /repos/${app_name}/. \"${app_dir}\""
echo " cd \"${app_dir}\" || exit 36487365"
fi
echo ' git pull'
echo ' else'
if [ ! "$app_dir" ]; then
echo " git_clone \"\$${app_name_upper}_REPO\" \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
else
echo " git_clone \"\$${app_name_upper}_REPO\" \"${app_dir}\""
fi
echo ' fi'
echo ''
if [ ! "$app_dir" ]; then
echo " if [ ! -d \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\" ]; then"
if [ "$app_repo" ]; then
echo " if [ -d /repos/${app_name} ]; then"
if [ $app_webui ]; then
echo " mkdir \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
fi
if [ ! "$app_dir" ]; then
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"
else
echo " cp -r -p /repos/${app_name}/. \"${app_dir}\""
echo " cd \"${app_dir}\" || exit 36487365"
fi
echo ' git pull'
echo ' else'
if [ ! "$app_dir" ]; then
echo " git_clone \"\$${app_name_upper}_REPO\" \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
else
echo " git_clone \"\$${app_name_upper}_REPO\" \"${app_dir}\""
fi
echo ' fi'
echo ''
if [ ! "$app_dir" ]; then
echo " if [ ! -d \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\" ]; then"
else
echo " if [ ! -d \"${app_dir}\" ]; then"
fi
echo " echo \$'Unable to clone ${app_name} repo'"
echo ' exit 87525'
echo ' fi'
echo ''
else
echo " if [ ! -d \"${app_dir}\" ]; then"
echo " mkdir -p \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
if [ "$app_dir" ]; then
echo " mkdir \"${app_dir}\""
fi
fi
echo " echo \$'Unable to clone ${app_name} repo'"
echo ' exit 87525'
echo ' fi'
echo ''
if [ ! "$app_dir" ]; then
echo " cd \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\" || exit 36587356"
else
echo " cd \"${app_dir}\" || exit 3463754637"
fi
echo " git checkout \"\$${app_name_upper}_COMMIT\" -b \"\$${app_name_upper}_COMMIT\""
echo " set_completion_param \"${app_name} commit\" \"\$${app_name_upper}_COMMIT\""
if [ "$app_repo" ]; then
echo " git checkout \"\$${app_name_upper}_COMMIT\" -b \"\$${app_name_upper}_COMMIT\""
echo " set_completion_param \"${app_name} commit\" \"\$${app_name_upper}_COMMIT\""
fi
if [ $app_webui ]; then
echo ''
echo " chmod g+w \"/var/www/\$${app_name_upper}_DOMAIN_NAME/htdocs\""
@ -951,7 +971,7 @@ if [ $app_daemon ]; then
echo " echo 'Description=${app_name}';"
echo " echo 'After=syslog.target';"
echo " echo 'After=network.target';"
echo " echo 'Documentation=${app_name_upper}_REPO";
echo " echo \"Documentation=\$${app_name_upper}_REPO\";";
echo " echo '';"
echo " echo '[Service]';"
echo " echo 'Type=simple';"

Loading…
Cancel
Save