back up files in bootstrap.sh
This commit is contained in:
+8
-17
@@ -22,6 +22,8 @@
|
||||
#### VARIABLES
|
||||
#
|
||||
|
||||
TIMESTAMP="$(date "+%Y%m%d%H%M%S")"
|
||||
|
||||
GIT_REPO_BASE="https://gitea.admin-a.hpetersenfamily.com/heath/ansible"
|
||||
GIT_REPO="${GIT_REPO_BASE}.git"
|
||||
GIT_REPO_BRANCH="${1:-"development"}"
|
||||
@@ -42,8 +44,8 @@ SKEL_profile_d="${SKEL}/.profile.d"
|
||||
SKEL_ansible_venv_sh="${SKEL_profile_d}/ansible-venv.sh"
|
||||
SKEL_profile="${SKEL}/.profile"
|
||||
|
||||
HPF_ANS_ansible_venv="\${HOME}/.ansible-venv"
|
||||
HPF_ANS_activate="${HPF_ANS_ansible_venv}/bin/activate"
|
||||
HPF_ANS_ansible_venv_dir="\${HOME}/.ansible-venv"
|
||||
HPF_ANS_activate="${HPF_ANS_ansible_venv_dir}/bin/activate"
|
||||
|
||||
HPF_ANS_bin="\${HOME}/bin"
|
||||
HPF_ANS_ansible_pull_sh="${HPF_ANS_bin}/ansible-pull.sh"
|
||||
@@ -100,7 +102,6 @@ add_groups_to_user () {
|
||||
|
||||
# $command_line
|
||||
as_hpf_ans () {
|
||||
#su --login hpf-ans --command "if [ -r \"${HPF_ANS_activate}\" ] ; then source \"${HPF_ANS_activate}\" ; fi ; ${1}"
|
||||
su --login hpf-ans --command "${1}"
|
||||
}
|
||||
|
||||
@@ -111,7 +112,7 @@ as_hpf_ans () {
|
||||
|
||||
# Make sure we're running as root
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "ERROR - Not running as root!" >&2
|
||||
echo "ERROR - Not running as root" >&2
|
||||
exit 100
|
||||
fi
|
||||
|
||||
@@ -131,7 +132,7 @@ system_groupadd hpf-sudo 700
|
||||
system_groupadd hpf-sudo-np 701
|
||||
|
||||
# Create /etc/sudoers.d/hpf to allow common sudo permissions
|
||||
rm "${ETC_sudoers_d_hpf}" 2>/dev/null
|
||||
if [ -e "${ETC_sudoers_d_hpf}" ] ; then mv "${ETC_sudoers_d_hpf}" "${ETC_sudoers_d_hpf}.${TIMESTAMP}" ; fi
|
||||
curl -o "${ETC_sudoers_d_hpf}" "${GIT_REPO_sudoers_d_hpf}"
|
||||
chown root:root "${ETC_sudoers_d_hpf}"; chmod u=rw,go= "${ETC_sudoers_d_hpf}"
|
||||
|
||||
@@ -150,18 +151,8 @@ fi
|
||||
system_useradd hpf-ans 800
|
||||
add_groups_to_user hpf-sudo-np hpf-ans
|
||||
|
||||
|
||||
as_hpf_ans "which ansible"
|
||||
exit 255
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Make sure .ansible-venv exists
|
||||
as_hpf_ans "if [ ! -d \"${HPF_ANS_ansible_venv}\" ] ; then virtualenv \"${HPF_ANS_ansible_venv}\" ; fi"
|
||||
as_hpf_ans "if [ ! -d \"${HPF_ANS_ansible_venv_dir}\" ] ; then virtualenv \"${HPF_ANS_ansible_venv_dir}\" ; fi"
|
||||
|
||||
# Make sure pip is up to date
|
||||
as_hpf_ans "pip install --upgrade pip"
|
||||
@@ -174,7 +165,7 @@ as_hpf_ans "mkdir -p \"${HPF_ANS_bin}\""
|
||||
as_hpf_ans "chown hpf-ans:hpf-ans \"${HPF_ANS_bin}\"; chmod u=rwx,go= \"${HPF_ANS_bin}\""
|
||||
|
||||
# Create ansible-pull.sh
|
||||
as_hpf_ans "rm \"${HPF_ANS_ansible_pull_sh}\" 2>/dev/null"
|
||||
as_hpf_ans "if [ -e \"${HPF_ANS_ansible_pull_sh}\" ] ; then mv \"${HPF_ANS_ansible_pull_sh}\" \"${HPF_ANS_ansible_pull_sh}.${TIMESTAMP}\" ; fi"
|
||||
as_hpf_ans "curl -o \"${HPF_ANS_ansible_pull_sh}\" \"${GIT_REPO_ansible_pull_sh}\""
|
||||
as_hpf_ans "chown hpf-ans:hpf-ans \"${HPF_ANS_ansible_pull_sh}\"; chmod u=rwx,go= \"${HPF_ANS_ansible_pull_sh}\""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user