Move script bin folder and config to src
This commit is contained in:
58
src/bin/init.sh
Normal file
58
src/bin/init.sh
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# AUTHOR: Clemens Schwaighofer
|
||||
# DATE: 2025/6/27
|
||||
# DESC: Setup basic variables
|
||||
|
||||
CONFIG_BASE="${BASE_FOLDER}../config/";
|
||||
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_BASE=("git");
|
||||
if [ -n "${USE_SUDO}" ]; then
|
||||
GIT_COMMAND_BASE=("sudo" "-u" "${SUDO_USER}" "git");.
|
||||
fi;
|
||||
|
||||
# add trailing slash if not set
|
||||
GIT_REPOSITORY_FOLDER="${GIT_REPOSITORY_FOLDER%/}/"
|
||||
CLONE_BASE="clone-base/"
|
||||
LOG_FOLDER="log/"
|
||||
|
||||
# base folder does not exist
|
||||
if [ ! -d "${GIT_REPOSITORY_FOLDER}" ]; then
|
||||
echo "Base folder: ${GIT_REPOSITORY_FOLDER} not found";
|
||||
exit;
|
||||
fi;
|
||||
|
||||
# branch name not set
|
||||
if [ -n "${BRANCH}" ]; then
|
||||
echo "No branch name given";
|
||||
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_BASE;
|
||||
|
||||
Reference in New Issue
Block a user