fix to not resolve HOME/tilde until user is created

This commit is contained in:
2026-07-05 17:10:54 -05:00
parent a13b358d2e
commit a08f47e134
+6 -16
View File
@@ -10,9 +10,7 @@ GIT_REPO="${GIT_REPO_BASE}.git"
GIT_REPO_ETC_SUDOERS_D_HPF="${GIT_REPO_BASE}/raw/branch/main/etc_sudoers_d_hpf" GIT_REPO_ETC_SUDOERS_D_HPF="${GIT_REPO_BASE}/raw/branch/main/etc_sudoers_d_hpf"
GIT_REPO_HOME_HPF_ANS_BIN_ANSIBLE_PULL_SH="${GIT_REPO_BASE}/raw/branch/main/home_hpf_ans_bin_ansible-pull.sh" GIT_REPO_HOME_HPF_ANS_BIN_ANSIBLE_PULL_SH="${GIT_REPO_BASE}/raw/branch/main/home_hpf_ans_bin_ansible-pull.sh"
HPF_ANS_BIN_DIR=~hpf VENV_DIRECTORY="\${HOME}/.ansible-venv"
VENV_DIRECTORY=~hpf-ans/.ansible-venv
VENV_ACTIVATE="${VENV_DIRECTORY}/bin/activate" VENV_ACTIVATE="${VENV_DIRECTORY}/bin/activate"
ANSIBLE_PULL_LOG="/var/log/ansible-pull.log" ANSIBLE_PULL_LOG="/var/log/ansible-pull.log"
@@ -70,11 +68,6 @@ as_hpf_ans () {
su --login hpf-ans -c "if [ -r \"${VENV_ACTIVATE}\" ] ; then source \"${VENV_ACTIVATE}\" ; fi ; ${1}" su --login hpf-ans -c "if [ -r \"${VENV_ACTIVATE}\" ] ; then source \"${VENV_ACTIVATE}\" ; fi ; ${1}"
} }
# $file_name
backup_file () {
mv "${1}" "${1}.backup-$(date "+%Y%m%d%H%M%S")"
}
# #
#### PROCESS #### PROCESS
@@ -107,7 +100,7 @@ add_groups_to_user "hpf-sudo-np" hpf-ans
# Create /etc/sudoers.d/hpf # Create /etc/sudoers.d/hpf
f="/etc/sudoers.d/hpf" f="/etc/sudoers.d/hpf"
backup_file "${f}" rm "${f}" 2>/dev/null
curl -o "$f" "${GIT_REPO_ETC_SUDOERS_D_HPF}" curl -o "$f" "${GIT_REPO_ETC_SUDOERS_D_HPF}"
chown root:root "$f" chown root:root "$f"
chmod u=rw,g=r,o= "$f" chmod u=rw,g=r,o= "$f"
@@ -122,15 +115,12 @@ as_hpf_ans "pip install --upgrade pip"
as_hpf_ans "pip install ansible" as_hpf_ans "pip install ansible"
# Create ~hpf-ans/bin directory # Create ~hpf-ans/bin directory
d=~hpf-ans/bin d="\${HOME}/bin"
if [ ! -d "${d}" ] ; then as_hpf_ans "mkdir -p \"${d}\"; chown hpf-ans:hpf-ans \"${d}\"; chmod ug=rwx,o= \"${d}\""
as_hpf_ans "mkdir -p \"${d}\""
as_hpf_ans "chown hpf-ans:hpf-ans \"${d}\"; chmod ug=rwx,o= \"${d}\""
fi
# Create ~hpf-ans/bin/ansible-pull.sh # Create ~hpf-ans/bin/ansible-pull.sh
f=~hpf-ans/bin/ansible-pull.sh f="\${HOME}/bin/ansible-pull.sh"
backup_file "${f}" as_hpf_ans "rm \"${f}\" 2>/dev/null"
as_hpf_ans "curl -o \"${f}\" \"${GIT_REPO_HOME_HPF_ANS_BIN_ANSIBLE_PULL_SH}\"" as_hpf_ans "curl -o \"${f}\" \"${GIT_REPO_HOME_HPF_ANS_BIN_ANSIBLE_PULL_SH}\""
as_hpf_ans "chown hpf-ans:hpf-ans \"${f}\"; chmod ug=rwx,o= \"${f}\"" as_hpf_ans "chown hpf-ans:hpf-ans \"${f}\"; chmod ug=rwx,o= \"${f}\""