adds delete with various tweaks
This commit is contained in:
parent
8fe340c33e
commit
a792a74864
121
src/delete.sh
Normal file
121
src/delete.sh
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# check that our enabled containers path is correct
|
||||||
|
[ -e "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available" ] || {
|
||||||
|
echo "[error] Available containers path ${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available does not exist."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# action to delete
|
||||||
|
function askToDelete() {
|
||||||
|
# some house cleaning
|
||||||
|
PS3_old=$PS3
|
||||||
|
# set the local value
|
||||||
|
local question
|
||||||
|
local path
|
||||||
|
local target
|
||||||
|
# now set the values
|
||||||
|
question="$1"
|
||||||
|
path="$2"
|
||||||
|
target="$3"
|
||||||
|
# some defaults
|
||||||
|
echo "${question}"
|
||||||
|
# set the terminal
|
||||||
|
export PS3="[select]: "
|
||||||
|
# Start our little Menu
|
||||||
|
select yn in "Yes" "No"; do
|
||||||
|
case $yn in
|
||||||
|
Yes ) sudo rm -rf "${path}"; echo "[notice] ${target} was deleted.";;
|
||||||
|
No ) echo "[notice] ${target} was not deleted.";;
|
||||||
|
esac
|
||||||
|
break
|
||||||
|
done
|
||||||
|
# restore the default
|
||||||
|
export PS3=$PS3_old
|
||||||
|
}
|
||||||
|
|
||||||
|
# get container available for deletion
|
||||||
|
function getContainer() {
|
||||||
|
# some house cleaning
|
||||||
|
PS3_old=$PS3
|
||||||
|
# some defaults
|
||||||
|
export PS3="Please select ${VDM_CONTAINER_TYPE} container deploy files to delete: "
|
||||||
|
# Start our little Menu
|
||||||
|
select menu in $(ls "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/"); do
|
||||||
|
case $REPLY in
|
||||||
|
*)
|
||||||
|
SELECTED="$menu"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
break
|
||||||
|
done
|
||||||
|
# restore the default
|
||||||
|
export PS3=$PS3_old
|
||||||
|
# return selection
|
||||||
|
echo "$SELECTED"
|
||||||
|
}
|
||||||
|
|
||||||
|
# set the container
|
||||||
|
CONTAINER="${1:-$CONTAINER}"
|
||||||
|
[ ${#CONTAINER} -ge 1 ] && [ -e "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${CONTAINER}" ] || {
|
||||||
|
CONTAINER=$(getContainer)
|
||||||
|
# make sure value was entered
|
||||||
|
[ ${#CONTAINER} -ge 1 ] && [ -e "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${CONTAINER}" ] || exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# disable
|
||||||
|
if [ -e "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${CONTAINER}" ]; then
|
||||||
|
# make sure the docker image is stopped
|
||||||
|
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${CONTAINER}/docker-compose.yml" down
|
||||||
|
# then remove soft link
|
||||||
|
rm "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${CONTAINER}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# remove the files with one last confirmation
|
||||||
|
askToDelete \
|
||||||
|
"Are you absolutely sure you would like to complete delete the ${VDM_CONTAINER_TYPE} ${CONTAINER} deploy files?" \
|
||||||
|
"${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${CONTAINER}" \
|
||||||
|
"${CONTAINER}"
|
||||||
|
|
||||||
|
# check that our project path is correct
|
||||||
|
[ -e "${VDM_PROJECT_PATH}" ] || {
|
||||||
|
echo "[error] Project path (${VDM_PROJECT_PATH}) does not exist."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# make sites available selection
|
||||||
|
function getProjectsAvailable() {
|
||||||
|
# some house cleaning
|
||||||
|
PS3_old=$PS3
|
||||||
|
# some defaults
|
||||||
|
export PS3="Please select persistent volume folder to delete: "
|
||||||
|
# Start our little Menu
|
||||||
|
select menu in $(ls "${VDM_PROJECT_PATH}"); do
|
||||||
|
case $REPLY in
|
||||||
|
*)
|
||||||
|
SELECTED="$menu"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
break
|
||||||
|
done
|
||||||
|
# restore the default
|
||||||
|
export PS3=$PS3_old
|
||||||
|
# return selection
|
||||||
|
echo "$SELECTED"
|
||||||
|
}
|
||||||
|
|
||||||
|
# set the local values
|
||||||
|
VDM_PROJECT="${2:-$VDM_PROJECT}"
|
||||||
|
# check that we have what we need
|
||||||
|
# shellcheck disable=SC2015
|
||||||
|
[ ${#VDM_PROJECT} -ge 1 ] && [ -d "${VDM_PROJECT_PATH}/${VDM_PROJECT}" ] || {
|
||||||
|
VDM_PROJECT=$(getProjectsAvailable)
|
||||||
|
# make sure value was entered
|
||||||
|
[ ${#VDM_PROJECT} -ge 1 ] && [ -d "${VDM_PROJECT_PATH}/${VDM_PROJECT}" ] || exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# remove the files with one last confirmation
|
||||||
|
askToDelete \
|
||||||
|
"Are you absolutely sure you would like to delete the ${VDM_PROJECT} persistent volume folders?" \
|
||||||
|
"${VDM_PROJECT_PATH}/${VDM_PROJECT}" \
|
||||||
|
"${VDM_PROJECT}"
|
50
src/fix.sh
50
src/fix.sh
@ -28,48 +28,54 @@ function getProjectsAvailable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# set the local values
|
# set the local values
|
||||||
vdm_project="${1:-$VDM_PROJECT}"
|
VDM_PROJECT="${1:-$VDM_PROJECT}"
|
||||||
# check that we have what we need
|
# check that we have what we need
|
||||||
[ ${#vdm_project} -ge 1 ] && [ -d "${VDM_PROJECT_PATH}/${vdm_project}" ] || {
|
# shellcheck disable=SC2015
|
||||||
vdm_project=$(getProjectsAvailable)
|
[ ${#VDM_PROJECT} -ge 1 ] && [ -d "${VDM_PROJECT_PATH}/${VDM_PROJECT}" ] || {
|
||||||
|
VDM_PROJECT=$(getProjectsAvailable)
|
||||||
# make sure value was entered
|
# make sure value was entered
|
||||||
[ ${#vdm_project} -ge 1 ] && [ -d "${VDM_PROJECT_PATH}/${vdm_project}" ] || exit
|
[ ${#VDM_PROJECT} -ge 1 ] && [ -d "${VDM_PROJECT_PATH}/${VDM_PROJECT}" ] || exit
|
||||||
}
|
}
|
||||||
|
|
||||||
### Fix the folder ownership of Joomla folders
|
### Fix the folder ownership of Joomla folders
|
||||||
#
|
#
|
||||||
echo "[notice] Fix the folder ownership of ${vdm_project} Joomla folders"
|
echo "[notice] Fix the folder ownership of ${VDM_PROJECT} Joomla folders"
|
||||||
#
|
#
|
||||||
sudo chown -R www-data:www-data "${VDM_PROJECT_PATH}/${vdm_project}/joomla"
|
sudo chown -R www-data:www-data "${VDM_PROJECT_PATH}/${VDM_PROJECT}/joomla"
|
||||||
sudo setfacl -R -m u:llewellyn:rwx "${VDM_PROJECT_PATH}/${vdm_project}/joomla"
|
|
||||||
|
|
||||||
### Fix the folder permissions for the Joomla websites
|
### Fix the folder permissions for the Joomla websites
|
||||||
#
|
#
|
||||||
echo "[notice] Fix the file and folder permissions for the ${vdm_project} Joomla website"
|
echo "[notice] Fix the file and folder permissions for the ${VDM_PROJECT} Joomla website"
|
||||||
#
|
#
|
||||||
# Change the file permissions
|
# Change the file permissions
|
||||||
sudo find "${VDM_PROJECT_PATH}/${vdm_project}/joomla" -type f -exec chmod 644 {} \;
|
sudo find "${VDM_PROJECT_PATH}/${VDM_PROJECT}/joomla" -type f -exec chmod 644 {} \;
|
||||||
sudo find "${VDM_PROJECT_PATH}/${vdm_project}/joomla/configuration.php" -type f -exec chmod 444 {} \;
|
sudo find "${VDM_PROJECT_PATH}/${VDM_PROJECT}/joomla/configuration.php" -type f -exec chmod 444 {} \;
|
||||||
[ -f "${VDM_PROJECT_PATH}/${vdm_project}/joomla/.htaccess" ] &&
|
[ -f "${VDM_PROJECT_PATH}/${VDM_PROJECT}/joomla/.htaccess" ] &&
|
||||||
sudo find "${VDM_PROJECT_PATH}/${vdm_project}/joomla/.htaccess" -type f -exec chmod 400 {} \;
|
sudo find "${VDM_PROJECT_PATH}/${VDM_PROJECT}/joomla/.htaccess" -type f -exec chmod 400 {} \;
|
||||||
[ -f "${VDM_PROJECT_PATH}/${vdm_project}/joomla/php.ini" ] &&
|
[ -f "${VDM_PROJECT_PATH}/${VDM_PROJECT}/joomla/php.ini" ] &&
|
||||||
sudo find "${VDM_PROJECT_PATH}/${vdm_project}/joomla/php.ini" -type f -exec chmod 400 {} \;
|
sudo find "${VDM_PROJECT_PATH}/${VDM_PROJECT}/joomla/php.ini" -type f -exec chmod 400 {} \;
|
||||||
# Change the folder permissions
|
# Change the folder permissions
|
||||||
sudo find /"home/${USER}/Projects/${vdm_project}/joomla" -type d -exec chmod 755 {} \;
|
sudo find /"home/${USER}/Projects/${VDM_PROJECT}/joomla" -type d -exec chmod 755 {} \;
|
||||||
# Change the image folder permissions
|
# Change the image folder permissions
|
||||||
# chmod 707 "${VDM_PROJECT_PATH}/${vdm_project}/joomla/images"
|
# chmod 707 "${VDM_PROJECT_PATH}/${VDM_PROJECT}/joomla/images"
|
||||||
# chmod 707 "${VDM_PROJECT_PATH}/${vdm_project}/joomla/images/stories"
|
# chmod 707 "${VDM_PROJECT_PATH}/${VDM_PROJECT}/joomla/images/stories"
|
||||||
|
|
||||||
|
### Fix the folder permissions so the active user (1000) can access the files
|
||||||
|
#
|
||||||
|
echo "[notice] Fix the folder permissions of ${VDM_PROJECT} joomla so user:1000 can access them"
|
||||||
|
#
|
||||||
|
sudo setfacl -R -m u:1000:rwx "${VDM_PROJECT_PATH}/${VDM_PROJECT}/joomla"
|
||||||
|
|
||||||
### Fix the folder ownership of database folders
|
### Fix the folder ownership of database folders
|
||||||
#
|
#
|
||||||
echo "[notice] Fix the folder ownership of ${vdm_project} database folders"
|
echo "[notice] Fix the folder ownership of ${VDM_PROJECT} database folders"
|
||||||
#
|
#
|
||||||
sudo chown -R systemd-coredump:systemd-coredump "${VDM_PROJECT_PATH}/${vdm_project}/db"
|
sudo chown -R systemd-coredump:systemd-coredump "${VDM_PROJECT_PATH}/${VDM_PROJECT}/db"
|
||||||
|
|
||||||
### Fix the folder permissions for the database files
|
### Fix the folder permissions for the database files
|
||||||
#
|
#
|
||||||
echo "[notice] Fix the file and folder permissions for the ${vdm_project} database files"
|
echo "[notice] Fix the file and folder permissions for the ${VDM_PROJECT} database files"
|
||||||
#
|
#
|
||||||
# Change the file permissions
|
# Change the file permissions
|
||||||
sudo find "${VDM_PROJECT_PATH}/${vdm_project}/db" -type f -exec chmod 660 {} \;
|
sudo find "${VDM_PROJECT_PATH}/${VDM_PROJECT}/db" -type f -exec chmod 660 {} \;
|
||||||
sudo find "${VDM_PROJECT_PATH}/${vdm_project}/db" -type d -exec chmod 700 {} \;
|
sudo find "${VDM_PROJECT_PATH}/${VDM_PROJECT}/db" -type d -exec chmod 700 {} \;
|
||||||
|
@ -336,4 +336,19 @@ buildContainer >"${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_SUBDOMAI
|
|||||||
chmod 600 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_SUBDOMAIN}.${VDM_DOMAIN}/docker-compose.yml"
|
chmod 600 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_SUBDOMAIN}.${VDM_DOMAIN}/docker-compose.yml"
|
||||||
# saved the file
|
# saved the file
|
||||||
echo "[save] ${VDM_CONTAINER_TYPE}:docker-compose.yml"
|
echo "[save] ${VDM_CONTAINER_TYPE}:docker-compose.yml"
|
||||||
|
# some house cleaning
|
||||||
|
PS3_old=$PS3
|
||||||
|
# ask if we should right now enable the container
|
||||||
|
echo "[question] Would you like to enable this new ${VDM_CONTAINER_TYPE} container?"
|
||||||
|
# set the terminal
|
||||||
|
export PS3="[select]: "
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
select yn in "Yes" "No"; do
|
||||||
|
case $yn in
|
||||||
|
Yes ) source "${VDM_SRC_PATH}/enable.sh" "${VDM_SUBDOMAIN}.${VDM_DOMAIN}";;
|
||||||
|
esac
|
||||||
|
break
|
||||||
|
done
|
||||||
|
# restore the default
|
||||||
|
export PS3=$PS3_old
|
||||||
echo "[setup] Completed!"
|
echo "[setup] Completed!"
|
||||||
|
@ -437,4 +437,19 @@ buildContainer "${VDM_MOUNT_PROJECTS}" >"${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/
|
|||||||
chmod 600 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_USER_NAME:-ubuntu}.${VDM_DOMAIN:-vdm.dev}/docker-compose.yml"
|
chmod 600 "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${VDM_USER_NAME:-ubuntu}.${VDM_DOMAIN:-vdm.dev}/docker-compose.yml"
|
||||||
# saved the file
|
# saved the file
|
||||||
echo "[save] ${VDM_CONTAINER_TYPE}:docker-compose.yml"
|
echo "[save] ${VDM_CONTAINER_TYPE}:docker-compose.yml"
|
||||||
|
# some house cleaning
|
||||||
|
PS3_old=$PS3
|
||||||
|
# ask if we should right now enable the container
|
||||||
|
echo "[question] Would you like to enable this new ${VDM_CONTAINER_TYPE} container?"
|
||||||
|
# set the terminal
|
||||||
|
export PS3="[select]: "
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
select yn in "Yes" "No"; do
|
||||||
|
case $yn in
|
||||||
|
Yes ) source "${VDM_SRC_PATH}/enable.sh" "${VDM_USER_NAME:-ubuntu}.${VDM_DOMAIN:-vdm.dev}";;
|
||||||
|
esac
|
||||||
|
break
|
||||||
|
done
|
||||||
|
# restore the default
|
||||||
|
export PS3=$PS3_old
|
||||||
echo "[setup] Completed!"
|
echo "[setup] Completed!"
|
||||||
|
@ -24,6 +24,7 @@ mkdir -p -m 700 "${VDM_REPO_PATH}/traefik"
|
|||||||
|
|
||||||
# set the local values
|
# set the local values
|
||||||
REMOVE_SECURE=''
|
REMOVE_SECURE=''
|
||||||
|
HTTP_SCHEME="https"
|
||||||
# check that we have what we need
|
# check that we have what we need
|
||||||
if [ "${VDM_SECURE,,}" != 'y' ] && [ "${VDM_SECURE,,}" != 'n' ]; then
|
if [ "${VDM_SECURE,,}" != 'y' ] && [ "${VDM_SECURE,,}" != 'n' ]; then
|
||||||
echo -n "[enter] Use letsencrypt (y/n): "
|
echo -n "[enter] Use letsencrypt (y/n): "
|
||||||
@ -59,6 +60,7 @@ else
|
|||||||
grep -q "VDM_SECURE=\"n\"" "${VDM_SRC_PATH}/.env" || echo "export VDM_SECURE=\"n\"" >>"${VDM_SRC_PATH}/.env"
|
grep -q "VDM_SECURE=\"n\"" "${VDM_SRC_PATH}/.env" || echo "export VDM_SECURE=\"n\"" >>"${VDM_SRC_PATH}/.env"
|
||||||
# remove secure from build
|
# remove secure from build
|
||||||
REMOVE_SECURE="#"
|
REMOVE_SECURE="#"
|
||||||
|
HTTP_SCHEME="http"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# build function
|
# build function
|
||||||
@ -73,11 +75,11 @@ services:
|
|||||||
image: "traefik:latest"
|
image: "traefik:latest"
|
||||||
command:
|
command:
|
||||||
- --entrypoints.web.address=:80
|
- --entrypoints.web.address=:80
|
||||||
${REMOVE_SECURE} - --entrypoints.websecure.address=:443
|
- --entrypoints.websecure.address=:443
|
||||||
# - --api.dashboard=true
|
# - --api.dashboard=true
|
||||||
# - --api.insecure=true
|
# - --api.insecure=true
|
||||||
- --providers.docker
|
- --providers.docker
|
||||||
- --log.level=ERROR
|
- --log.level=INFO
|
||||||
${REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.httpchallenge=true
|
${REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.httpchallenge=true
|
||||||
${REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.keytype=RSA4096
|
${REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.keytype=RSA4096
|
||||||
${REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.email=${VDM_SECURE_EMAIL:-user@demo.com}
|
${REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.email=${VDM_SECURE_EMAIL:-user@demo.com}
|
||||||
@ -88,7 +90,7 @@ ${REMOVE_SECURE} - --certificatesresolvers.vdmresolver.acme.httpchallenge.e
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
${REMOVE_SECURE} - "443:443"
|
- "443:443"
|
||||||
# - "8080:8080"
|
# - "8080:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
@ -99,8 +101,8 @@ ${REMOVE_SECURE} - "\${VDM_PROJECT_PATH}/traefik/acme.json:/acme.json"
|
|||||||
# settings for all containers
|
# settings for all containers
|
||||||
- "traefik.http.routers.http-catchall.rule=hostregexp(\`{host:.+}\`)"
|
- "traefik.http.routers.http-catchall.rule=hostregexp(\`{host:.+}\`)"
|
||||||
- "traefik.http.routers.http-catchall.entrypoints=web"
|
- "traefik.http.routers.http-catchall.entrypoints=web"
|
||||||
${REMOVE_SECURE} - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
|
- "traefik.http.routers.http-catchall.middlewares=redirect-to-me"
|
||||||
${REMOVE_SECURE} - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
|
- "traefik.http.middlewares.redirect-to-me.redirectscheme.scheme=${HTTP_SCHEME}"
|
||||||
networks:
|
networks:
|
||||||
- traefik
|
- traefik
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user