pkgname=test_server _service_user=$pkgname _service_group=$pkgname _admin_group="${pkgname}_admin" _data_dir=/var/${pkgname}/data _log_dir=/var/log/${pkgname} _cache_dir=/var/cache/${pkgname} _sass_cache_directory=$_cache_dir post_install() { if !getent group $_admin_group >/dev/null; then groupadd $_admin_group fi if !getent passwd $_service_user >/dev/null; then useradd -m $_service_user fi for path in $_log_dir $_sass_cache_directory; do chown -R $_service_user:$_service_group $path done # Admins are allowed to write, service is allowd to read, others can do nothing chown :$_admin_group $_data_dir setfacl -m g:$_service_group:rx $_data_dir echo "" echo "Please place a config file at one of the following places:" echo "" echo " * $HOME/.config/test_server/config.yaml" echo " * $HOME/.test_server/config.yaml" echo " * /etc/test_server/config.yaml" echo "" echo "The package contains a \"config.yaml\" which has been placed at /etc/test_server/config.yaml during package install. Feel free to modify it." echo "" } post_upgrade() { post_install } pre_remove() { systemctl stop $pkgname systemctl disable $pkgname } post_remove() { echo "" echo "Please remove the home directory of the service user ${_service_user} yourself." echo "" if !getent group $_admin_group >dev/null; then groupdel $_admin_group fi if !getent group $_service_group >/dev/null; then groupdel $_service_group fi if !getent passwd $_service_user >/dev/null; then userdel $_service_user fi }