Skip to content

Commit

Permalink
add check for git setup
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvinSchiller committed Nov 15, 2023
1 parent 9c12249 commit 1fabb92
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
19 changes: 19 additions & 0 deletions installation/includes/02_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,25 @@ verify_chmod_chown() {
done
}

# Check if the dir(s) has/have the expected owner and modifications
verify_dir_chmod_chown() {
local mod_expected=$1
local user_expected=$2
local group_expected=$3

for dir in "$@"
do
test ! -f ${dir} && exit_on_error "ERROR: ${dir} does not exists or is not a dir!"

mod_actual=$(stat --format '%a' "${dir}")
user_actual=$(stat -c '%U' "${dir}")
group_actual=$(stat -c '%G' "${dir}")
test ! "${mod_expected}" -eq "${mod_actual}" && exit_on_error "ERROR: ${dir} actual mod (${mod_actual}) differs from expected (${mod_expected})!"
test ! "${user_expected}" == "${user_actual}" && exit_on_error "ERROR: ${dir} actual owner (${user_actual}) differs from expected (${user_expected})!"
test ! "${group_expected}" == "${group_actual}" && exit_on_error "ERROR: ${dir} actual group (${group_actual}) differs from expected (${group_expected})!"
done
}

verify_file_contains_string() {
local string="$1"
local file="$2"
Expand Down
10 changes: 9 additions & 1 deletion installation/routines/setup_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ _git_convert_tardir_git_repo() {
if [[ "${HASH_BRANCH}" != "${HASH_HEAD}" ]]; then
echo "*** IMPORTANT NOTICE *******************************"
echo "* Your requested branch has moved on while you were installing."
echo "* Don't worry! We will stay within the the exact download version!"
echo "* Don't worry! We will stay within the exact download version!"
echo "* But we set up the git repo to be ready for updating."
echo "* To start updating (observe updating guidelines!), do:"
echo "* $ git pull origin $GIT_BRANCH"
Expand All @@ -137,12 +137,20 @@ _git_convert_tardir_git_repo() {
unset HASH_BRANCH
}

_jukebox_core_check () {
echo "Check Git & repository installation" | tee /dev/fd/3

verify_apt_packages git
verify_dir_chmod_chown "${INSTALLATION_PATH}/.git"
}

init_git_repo_from_tardir() {
echo "Install Git & init repository" | tee /dev/fd/3

cd "${INSTALLATION_PATH}" || exit_on_error
_git_install_os_dependencies
_git_convert_tardir_git_repo
_jukebox_core_check

echo "DONE: init_git_repo_from_tardir"
}

0 comments on commit 1fabb92

Please sign in to comment.