mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Use releases tarballs rather than git master.
- upgrade to ihatemoney 0.9 - refactor some code into a `_common.sh`
This commit is contained in:
parent
b0ae7b8c77
commit
c114aa6ac8
3 changed files with 61 additions and 17 deletions
32
scripts/_common.sh
Normal file
32
scripts/_common.sh
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
fetch_and_extract() {
|
||||||
|
local DESTDIR=$1
|
||||||
|
local OWNER_USER=${2:-admin}
|
||||||
|
|
||||||
|
VERSION=0.9
|
||||||
|
SHA256=4dab1018563097b309848de5873d63b913390a66327871b0c958ed8516762870
|
||||||
|
SOURCE_URL="https://github.com/spiral-project/ihatemoney/archive/${VERSION}.tar.gz"
|
||||||
|
|
||||||
|
# retrieve and extract Roundcube tarball
|
||||||
|
tarball="/tmp/ihatemoney.tar.bz2"
|
||||||
|
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
|
||||||
|
}
|
|
@ -4,6 +4,9 @@ set -eu
|
||||||
# Source YunoHost helpers
|
# Source YunoHost helpers
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Source local utils
|
||||||
|
source _common.sh
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$YNH_APP_ARG_PATH
|
path=$YNH_APP_ARG_PATH
|
||||||
|
@ -56,19 +59,18 @@ ynh_app_setting_set $app is_public "$is_public"
|
||||||
# Install debian packages dependencies
|
# Install debian packages dependencies
|
||||||
sudo apt-get install -y -qq python-dev python-virtualenv supervisor libmysqlclient-dev
|
sudo apt-get install -y -qq python-dev python-virtualenv supervisor libmysqlclient-dev
|
||||||
# Create the dedicated user
|
# Create the dedicated user
|
||||||
sudo useradd ihatemoney -d /opt/yunohost/ihatemoney/
|
sudo useradd ihatemoney -d /opt/yunohost/ihatemoney/ --create-home
|
||||||
|
|
||||||
|
# Install source
|
||||||
|
fetch_and_extract /opt/yunohost/ihatemoney/src/ ihatemoney
|
||||||
|
|
||||||
# Prepare venv
|
# Prepare venv
|
||||||
sudo virtualenv /opt/yunohost/ihatemoney/venv
|
sudo virtualenv /opt/yunohost/ihatemoney/venv
|
||||||
sudo /opt/yunohost/ihatemoney/venv/bin/pip install -r ../sources/budget/requirements.txt
|
sudo /opt/yunohost/ihatemoney/venv/bin/pip install -r /opt/yunohost/ihatemoney/src/requirements.txt
|
||||||
sudo /opt/yunohost/ihatemoney/venv/bin/pip install gunicorn>=19.3.0 MySQL-python
|
sudo /opt/yunohost/ihatemoney/venv/bin/pip install gunicorn>=19.3.0 MySQL-python
|
||||||
|
|
||||||
# Install source
|
# Fix permissions
|
||||||
sudo cp -r ../sources/ /opt/yunohost/ihatemoney/src/
|
fix_permissions /opt/yunohost/ihatemoney/src
|
||||||
sudo find /opt/yunohost/ihatemoney/src/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
|
||||||
sudo find /opt/yunohost/ihatemoney/src/ -type d | while read LINE; do sudo chmod 755 "$LINE" ; done
|
|
||||||
sudo chown -R ihatemoney:ihatemoney /opt/yunohost/ihatemoney/src
|
|
||||||
sudo chown -R www-data:www-data /opt/yunohost/ihatemoney/src/budget/static
|
|
||||||
|
|
||||||
# Create various dirs
|
# Create various dirs
|
||||||
sudo install -o ihatemoney -g ihatemoney -m 755 \
|
sudo install -o ihatemoney -g ihatemoney -m 755 \
|
||||||
|
|
|
@ -3,14 +3,22 @@ set -eu
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
|
||||||
|
# The main logic is to
|
||||||
|
# - install in a src-new folder
|
||||||
|
# - upgrade dependencies
|
||||||
|
# - if everything OK, rename src-new to src
|
||||||
|
|
||||||
# Installation paths
|
# Installation paths
|
||||||
INSTALL_DIR=/opt/yunohost/ihatemoney
|
INSTALL_DIR=/opt/yunohost/ihatemoney
|
||||||
PIP=${INSTALL_DIR}/venv/bin/pip
|
PIP=${INSTALL_DIR}/venv/bin/pip
|
||||||
REQUIREMENTS=${INSTALL_DIR}/src/budget/requirements.txt
|
NEW_REQUIREMENTS=${INSTALL_DIR}/src-new/requirements.txt
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source YunoHost helpers
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Source local utils
|
||||||
|
source _common.sh
|
||||||
|
|
||||||
# Optionaly upgrade arg to typed boolean form
|
# Optionaly upgrade arg to typed boolean form
|
||||||
|
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
|
@ -25,17 +33,19 @@ fi
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
ynh_app_setting_set "$app" is_public "$is_public"
|
||||||
|
|
||||||
# Upgrade code
|
# Upgrade code
|
||||||
sudo rsync -a --delete-after ../sources/ ${INSTALL_DIR}/src/
|
fetch_and_extract ${INSTALL_DIR}/src-new/ ihatemoney
|
||||||
sudo find ${INSTALL_DIR}/src/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
|
||||||
sudo find ${INSTALL_DIR}/src/ -type d | while read LINE; do sudo chmod 755 "$LINE" ; done
|
|
||||||
sudo chown -R ihatemoney:ihatemoney /opt/yunohost/ihatemoney/src
|
|
||||||
sudo chown -R www-data:www-data /opt/yunohost/ihatemoney/src/budget/static
|
|
||||||
|
|
||||||
# Re-create settings symlink
|
fix_permissions ${INSTALL_DIR}/src-new/
|
||||||
sudo ln -s /etc/ihatemoney/settings.py /opt/yunohost/ihatemoney/src/budget/settings.py
|
|
||||||
|
|
||||||
# Upgrade dependencies
|
# Upgrade dependencies
|
||||||
sudo ${PIP} install -r ${REQUIREMENTS}
|
sudo ${PIP} install -r ${NEW_REQUIREMENTS}
|
||||||
|
|
||||||
|
# Everything went ok ? Let's keep this code.
|
||||||
|
sudo rm -rf ${INSTALL_DIR}/src
|
||||||
|
sudo mv ${INSTALL_DIR}/src-new ${INSTALL_DIR}/src
|
||||||
|
|
||||||
|
# Re-create settings symlink
|
||||||
|
sudo ln -s /etc/ihatemoney/settings.py ${INSTALL_DIR}/src/budget/settings.py
|
||||||
|
|
||||||
# Settings are not very likely to change, and that script may be
|
# Settings are not very likely to change, and that script may be
|
||||||
# adapted to handle it in case.
|
# adapted to handle it in case.
|
||||||
|
|
Loading…
Add table
Reference in a new issue