Basic script check in
This is not completed and under development
This commit is contained in:
50
bin/init.sh
Normal file
50
bin/init.sh
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CONFIG_BASE="${BASE_FOLDER}../config/";
|
||||
echo "CONFIG: ${CONFIG_BASE} ";
|
||||
if [ -f "${CONFIG_BASE}webhook.cfg" ]; then
|
||||
# shellcheck source=../config/webhook.cfg"
|
||||
# shellcheck disable=SC1091
|
||||
source <(grep "=" "${CONFIG_BASE}webhook.cfg" | sed 's/ *= */=/g')
|
||||
fi;
|
||||
if [ "${USE_SUDO}" != "0" ] && ! id "${SUDO_USER}" &>/dev/null; then
|
||||
echo "sudo user ${SUDO_USER} does not exist";
|
||||
exit;
|
||||
fi;
|
||||
# check that user exist
|
||||
# check that git exists
|
||||
if [ -z "$(command -v git)" ]; then
|
||||
echo "git is not installed";
|
||||
exit;
|
||||
fi;
|
||||
GIT_COMMAND="git";
|
||||
if [ -n "${USE_SUDO}" ]; then
|
||||
GIT_COMMAND="sudo -u ${SUDO_USER} git";
|
||||
fi;
|
||||
|
||||
# branch name not set
|
||||
if [ -n "${BRANCH}" ]; then
|
||||
echo "No branch name given";
|
||||
exit;
|
||||
fi;
|
||||
|
||||
# base folder does not exist
|
||||
if [ ! -d "${GIT_REPOSITORY_FOLDER}" ]; then
|
||||
echo "Base folder: ${GIT_REPOSITORY_FOLDER} not found";
|
||||
exit;
|
||||
fi;
|
||||
|
||||
# check that log folder exists
|
||||
if [ ! -d "${GIT_REPOSITORY_FOLDER}${LOG_FOLDER}" ]; then
|
||||
echo "Log folder does not exist: ${GIT_REPOSITORY_FOLDER}${LOG_FOLDER}";
|
||||
exit;
|
||||
fi;
|
||||
|
||||
# check that the base clone folder exists
|
||||
if [ ! -d "${GIT_REPOSITORY_FOLDER}${CLONE_BASE}" ]; then
|
||||
echo "Clone base folder does not exist: ${GIT_REPOSITORY_FOLDER}${CLONE_BASE}";
|
||||
exit;
|
||||
fi;
|
||||
|
||||
export GIT_COMMAND;
|
||||
|
||||
Reference in New Issue
Block a user