2017-06-17 17:28:57 +02:00
|
|
|
### Constants
|
|
|
|
|
|
|
|
nginx_conf_path="/etc/nginx/conf.d/${domain}.d/ihatemoney.conf"
|
|
|
|
supervisor_conf_path="/etc/supervisor/conf.d/ihatemoney.conf"
|
|
|
|
gunicorn_conf_path="/etc/ihatemoney/gunicorn.conf.py"
|
2017-06-21 13:30:48 +02:00
|
|
|
ihatemoney_conf_path="/etc/ihatemoney/ihatemoney.cfg"
|
2017-06-17 17:28:57 +02:00
|
|
|
INSTALL_DIR="/opt/yunohost/ihatemoney"
|
|
|
|
|
|
|
|
|
|
|
|
### Functions
|
|
|
|
|
2017-06-17 00:22:16 +02:00
|
|
|
fetch_and_extract() {
|
|
|
|
local DESTDIR=$1
|
|
|
|
local OWNER_USER=${2:-admin}
|
|
|
|
|
2017-06-20 23:17:07 +02:00
|
|
|
VERSION=1.0
|
|
|
|
SHA256=e2ad6e56b161f13911c1c378aad79656bbdfce495189d80f997414803859348e
|
2017-06-17 00:22:16 +02:00
|
|
|
SOURCE_URL="https://github.com/spiral-project/ihatemoney/archive/${VERSION}.tar.gz"
|
|
|
|
|
2017-06-24 13:55:46 +02:00
|
|
|
tarball="/tmp/ihatemoney.tar.gz"
|
2017-06-17 00:22:16 +02:00
|
|
|
rm -f "$tarball"
|
|
|
|
|
|
|
|
wget -q -O "$tarball" "$SOURCE_URL" \
|
|
|
|
|| ynh_die "Unable to download tarball"
|
|
|
|
echo "$SHA256 $tarball" | sha256sum -c >/dev/null \
|
|
|
|
|| ynh_die "Invalid checksum of downloaded tarball"
|
|
|
|
test -d $DESTDIR || sudo mkdir $DESTDIR
|
|
|
|
sudo tar xaf "${tarball}" -C "$DESTDIR" --strip-components 1\
|
|
|
|
|| ynh_die "Unable to extract tarball"
|
|
|
|
|
|
|
|
rm -f "$tarball"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fix_permissions() {
|
|
|
|
local SRC_DIR=$1
|
|
|
|
|
|
|
|
sudo find $SRC_DIR -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
|
|
|
sudo find $SRC_DIR -type d | while read LINE; do sudo chmod 755 "$LINE" ; done
|
|
|
|
sudo chown -R ihatemoney:ihatemoney $SRC_DIR
|
|
|
|
sudo chown -R www-data:www-data ${SRC_DIR}/budget/static
|
|
|
|
}
|
2017-06-18 17:11:10 +02:00
|
|
|
|
|
|
|
|
2017-06-19 09:35:17 +02:00
|
|
|
install_apt_dependencies() {
|
2018-02-17 00:20:10 +01:00
|
|
|
sudo apt-get install -y -qq python3-dev python3-virtualenv supervisor libmysqlclient-dev
|
2017-06-19 09:35:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
create_unix_user() {
|
|
|
|
sudo mkdir -p /opt/yunohost
|
|
|
|
sudo useradd ihatemoney -d /opt/yunohost/ihatemoney/ --create-home || ynh_die "User creation failed"
|
|
|
|
}
|
|
|
|
|
|
|
|
create_system_dirs() {
|
|
|
|
sudo install -o ihatemoney -g ihatemoney -m 755 -d \
|
|
|
|
/var/log/ihatemoney \
|
|
|
|
/etc/ihatemoney
|
|
|
|
sudo mkdir -p /opt/yunohost
|
|
|
|
}
|
|
|
|
|
2018-02-17 00:20:10 +01:00
|
|
|
init_virtualenv () {
|
|
|
|
sudo virtualenv /opt/yunohost/ihatemoney/venv --python /usr/bin/python3
|
|
|
|
}
|
|
|
|
|
2017-06-18 17:11:10 +02:00
|
|
|
### Backported helpers (from testing)
|
|
|
|
|
|
|
|
|
|
|
|
# Add path
|
|
|
|
ynh_normalize_url_path () {
|
|
|
|
path_url=$1
|
|
|
|
test -n "$path_url" || ynh_die "ynh_normalize_url_path expect a URL path as first argument and received nothing."
|
|
|
|
if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a /
|
|
|
|
path_url="/$path_url" # Add / at begin of path variable
|
|
|
|
fi
|
|
|
|
if [ "${path_url:${#path_url}-1}" == "/" ] && [ ${#path_url} -gt 1 ]; then # If the last character is a / and that not the only character.
|
|
|
|
path_url="${path_url:0:${#path_url}-1}" # Delete the last character
|
|
|
|
fi
|
|
|
|
echo $path_url
|
|
|
|
}
|