adds fix and setup

This commit is contained in:
Llewellyn van der Merwe 2021-06-25 14:31:58 +02:00
parent 6dc2131558
commit c38d3722d3
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
2 changed files with 126 additions and 0 deletions

75
src/fix.sh Normal file
View File

@ -0,0 +1,75 @@
#!/bin/bash
# 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 project to fix: "
# 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="${1:-$VDM_PROJECT}"
# check that we have what we need
[ ${#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
}
### Fix the folder ownership of 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 setfacl -R -m u:llewellyn:rwx "${VDM_PROJECT_PATH}/${vdm_project}/joomla"
### Fix the folder permissions for the Joomla websites
#
echo "[notice] Fix the file and folder permissions for the ${vdm_project} Joomla website"
#
# 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/configuration.php" -type f -exec chmod 444 {} \;
[ -f "${VDM_PROJECT_PATH}/${vdm_project}/joomla/.htaccess" ] &&
sudo find "${VDM_PROJECT_PATH}/${vdm_project}/joomla/.htaccess" -type f -exec chmod 400 {} \;
[ -f "${VDM_PROJECT_PATH}/${vdm_project}/joomla/php.ini" ] &&
sudo find "${VDM_PROJECT_PATH}/${vdm_project}/joomla/php.ini" -type f -exec chmod 400 {} \;
# Change the folder permissions
sudo find /"home/${USER}/Projects/${vdm_project}/joomla" -type d -exec chmod 755 {} \;
# Change the image folder permissions
# chmod 707 "${VDM_PROJECT_PATH}/${vdm_project}/joomla/images"
# chmod 707 "${VDM_PROJECT_PATH}/${vdm_project}/joomla/images/stories"
### Fix the folder ownership of 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"
### Fix the folder permissions for the database files
#
echo "[notice] Fix the file and folder permissions for the ${vdm_project} database files"
#
# 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 d -exec chmod 700 {} \;

51
src/setup.sh Normal file
View File

@ -0,0 +1,51 @@
#!/bin/bash
# check that our repository path is correct
[ -e "${VDM_SRC_PATH}" ] || {
echo "[error] Source path (${VDM_SRC_PATH}) does not exist."
exit 1
}
# check that our projects path is correct
[ -e "${VDM_PROJECT_PATH}" ] || {
echo "[error] Projects path (${VDM_PROJECT_PATH}) does not exist."
exit 1
}
# get container type
function getContainerType() {
# some house cleaning
PS3_old=$PS3
# some defaults
export PS3="Please select the kind of container to setup: "
# Start our little Menu (only these two for now)
select menu in "joomla" "openssh"; 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_CONTAINER_TYPE="${1:-$VDM_CONTAINER_TYPE}"
# check that we have what we need
[ ${#VDM_CONTAINER_TYPE} -ge 1 ] || {
VDM_CONTAINER_TYPE=$(getContainerType)
# make sure value was entered
[ ${#VDM_CONTAINER_TYPE} -ge 1 ] || {
echo "[error] Wrong container type selected"
exit 1
}
}
export VDM_CONTAINER_TYPE
# run that container setup script
# shellcheck disable=SC1090
source "${VDM_SRC_PATH}/setup-${VDM_CONTAINER_TYPE}.sh"