Skip to content

Commit

Permalink
Merge pull request #25 from ivanleoncz/issue_21/review/add_app_instal…
Browse files Browse the repository at this point in the history
…l_on_opt_for_install_script

Adding install definition for /opt
  • Loading branch information
ivanleoncz committed Dec 3, 2020
2 parents 957568e + 53cd98a commit 603d234
Showing 1 changed file with 37 additions and 15 deletions.
52 changes: 37 additions & 15 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
#
# Author: @ivanleoncz

# ---------------------------------------------------------------------------
# Attention
# ---------------------------------------------------------------------------
# These variables are used in two locations:
# 1. Here.
# 2. gen_config_files.py
#
# Leave them as it is, specially GEN_CALLER, unless you have a good reason.
# ---------------------------------------------------------------------------
export USER="pycaptive"
export CONF_DIR="/etc/pycaptive"
export INSTALL_DIR="/opt/pycaptive"
export GEN_CALLER="install.sh"

help () {
basename $0
Expand All @@ -15,26 +28,35 @@ help () {
}

install () {
PYCAPTIVE_ETC="/etc/pycaptive"
echo "[INFO]: creating pycaptive user"
/usr/bin/sudo /usr/sbin/useradd pycaptive -s /usr/sbin/nologin
echo "[INFO]: creating ${PYCAPTIVE_ETC} directory"
/bin/mkdir /etc/pycaptive
echo "[INFO]: installing pycaptive.ini to ${PYCAPTIVE_ETC} directory"
/usr/bin/install -m 664 -o pycaptive -g pycaptive app/pycaptive.ini /etc/pycaptive
echo "[INFO]: defining owner of ${PYCAPTIVE_ETC} directory"
/bin/chown pycaptive:pycaptive ${PYCAPTIVE_ETC}
echo "[INFO]: defining permission of ${PYCAPTIVE_ETC} directory"
/bin/chmod 775 ${PYCAPTIVE_ETC}
echo "[INFO]: creating ${USER} user"
/usr/bin/sudo /usr/sbin/useradd ${USER} -s /usr/sbin/nologin
echo "[INFO]: creating ${CONF_DIR} directory"
/bin/mkdir ${CONF_DIR}
echo "[INFO]: installing pycaptive.ini to ${CONF_DIR} directory"
/usr/bin/install -m 664 -o ${USER} -g ${USER} app/pycaptive.ini ${CONF_DIR}
echo "[INFO]: defining ${USER} as owner of ${CONF_DIR} directory"
/bin/chown ${USER}:${USER} ${CONF_DIR}
echo "[INFO]: defining permissions of ${CONF_DIR} directory"
/bin/chmod 775 ${CONF_DIR}
echo "[INFO]: installing repo files at ${INSTALL_DIR} directory"
/usr/bin/rsync -a . ${INSTALL_DIR} --exclude .git --exclude .gitignore
echo "[INFO]: defining ${USER} as owner of ${INSTALL_DIR} directory"
/bin/chown -R ${USER}:${USER} ${INSTALL_DIR}
echo "[INFO]: defining permissions on ${INSTALL_DIR} directory"
/usr/bin/find ${INSTALL_DIR} -type d -exec chmod 775 {} \;
/usr/bin/find ${INSTALL_DIR} -type f \( -name "*.py" -o -name "*.sh" \) -exec chmod 554 {} \;
echo "[INFO]: generating configuration files for services, based on gen_templates files"
python3 gen_config_files.py
}


uninstall () {
PYCAPTIVE_ETC="/etc/pycaptive"
echo "[INFO]: deleting ${PYCAPTIVE_ETC} directory and its contents"
/bin/rm -rf /etc/pycaptive
echo "[INFO]: deleting ${CONF_DIR} directory and its contents"
/bin/rm -rf ${CONF_DIR}
echo "[INFO]: deleting ${INSTALL_DIR} directory and its contents"
/bin/rm -rf ${INSTALL_DIR}
echo "[INFO]: deleting pycaptive user"
/usr/sbin/userdel pycaptive
/usr/sbin/userdel ${USER}
}

if [[ "$UID" == 0 ]]; then
Expand Down

0 comments on commit 603d234

Please sign in to comment.