1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wallabag2_ynh.git synced 2024-10-01 13:35:06 +02:00
wallabag2_ynh/scripts/_common.sh
2021-06-11 16:16:53 +02:00

41 lines
1.2 KiB
Bash

#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="php$YNH_DEFAULT_PHP_VERSION-cli php$YNH_DEFAULT_PHP_VERSION-mysql php$YNH_DEFAULT_PHP_VERSION-json php$YNH_DEFAULT_PHP_VERSION-gd php$YNH_DEFAULT_PHP_VERSION-tidy php$YNH_DEFAULT_PHP_VERSION-curl php$YNH_DEFAULT_PHP_VERSION-php-gettext php$YNH_DEFAULT_PHP_VERSION-redis"
#=================================================
# PERSONAL HELPERS
#=================================================
function set_permissions {
# Set permissions to app files
chown -R $app:www-data $final_path
chmod -R g=u,g-w,o-rwx $final_path
# Restrict rights to Wallabag user only
chmod 600 $wb_conf
if [ -e $final_path/var/cache/prod/appProdProjectContainer.php ]; then
chmod 700 $final_path/var/cache/prod/appProdProjectContainer.php
fi
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
ynh_exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}