2018-02-11 01:20:58 +01:00
#=================================================
# SET ALL CONSTANTS
#=================================================
2016-12-27 10:44:40 +01:00
2023-08-08 23:21:11 +02:00
time_zone = $( cat /etc/timezone)
2023-10-04 20:56:57 +02:00
python_version = " $( python3 -V | cut -d' ' -f2 | cut -d. -f1-2) "
2017-12-09 20:56:20 +01:00
2024-04-12 22:19:27 +02:00
# Create special path with / at the end
if [ [ $path = = '/' ] ]
then
path2 = " $path "
else
path2 = " $path / "
fi
2018-02-11 01:20:58 +01:00
#=================================================
# DEFINE ALL COMMON FONCTIONS
#=================================================
2024-04-21 01:50:52 +02:00
install_pkg_conf( ) {
# Install manually pkgconf
# WARNING don't move this to dependencies
# We install this manually because we have an issue between pkgconf and pkg-config.
# If pkg-config is already installed on the system we can't declare pkgconf as dependency as pkg-config need to be removed to install pkgconf (note that pkgconf replace pkg-config and both can't be installed)
ynh_apt install pkgconf
}
2017-07-21 14:56:41 +02:00
install_dependance( ) {
2022-08-23 06:24:57 +02:00
ynh_add_swap --size= 2000
2023-10-04 20:56:57 +02:00
# Clean venv is it was on python3 with old version in case major upgrade of debian
if [ ! -e $install_dir /venv/bin/python3 ] || [ ! -e $install_dir /venv/lib/python$python_version ] ; then
ynh_secure_remove --file= $install_dir /venv/bin
ynh_secure_remove --file= $install_dir /venv/lib
ynh_secure_remove --file= $install_dir /venv/lib64
ynh_secure_remove --file= $install_dir /venv/include
ynh_secure_remove --file= $install_dir /venv/share
ynh_secure_remove --file= $install_dir /venv/pyvenv.cfg
fi
# Create venv if it don't exist
test -e $install_dir /venv/bin/python3 || python3 -m venv $install_dir /venv
u_arg = 'u'
set +$u_arg ;
source $install_dir /venv/bin/activate
set -$u_arg ;
2021-03-20 19:04:25 +01:00
2020-02-19 22:00:10 +01:00
# Note that we install imageio to force the dependance, without this imageio 2.8 is installed and it need python3.5
2023-10-05 08:20:30 +02:00
if [ $( lsb_release --codename --short) = = "bookworm" ] ; then
# Fix cffi installtion issue cf: https://github.com/haiwen/seahub/issues/5166
pip3 install --upgrade 'cffi==1.15.1'
sed -e "s|1.14.0|1.15.1|" -i $install_dir /seafile-server-$seafile_version /seahub/thirdpart/cffi/__init__.py
else
pip3 install --upgrade cffi = = 1.14.0
fi
2023-10-25 22:23:20 +02:00
if [ -n " $( uname -m | grep x86_64) " ] ; then
py_dependancy = "django==3.2.* Pillow<10.0.0 pylibmc captcha jinja2 SQLAlchemy<2 django-pylibmc django-simple-captcha python3-ldap mysqlclient pycryptodome==3.12.0 lxml python3-ldap"
else
py_dependancy = "lxml python3-ldap"
fi
pip3 install --upgrade --timeout= 3600 $py_dependancy
2023-10-04 20:56:57 +02:00
set +$u_arg ;
deactivate
set -$u_arg ;
2019-10-11 21:40:07 +02:00
ynh_del_swap
2023-10-04 20:56:57 +02:00
# Create symbolic link to venv package on seahub
ls $install_dir /venv/lib/python$python_version /site-packages | while read f; do
if [ ! -e " $install_dir /seafile-server- $seafile_version /seahub/thirdpart/ $f " ] ; then
ln -s ../../../venv/lib/python$python_version /site-packages/$f $install_dir /seafile-server-$seafile_version /seahub/thirdpart/$f
fi
done
2017-01-31 23:25:17 +01:00
}
2019-06-11 22:28:26 +02:00
set_permission( ) {
2023-12-18 14:34:09 +01:00
chown -R $app :$app $install_dir
2023-10-04 20:56:57 +02:00
chmod -R u+rwX,g-wx,o= $install_dir
2023-08-08 23:21:11 +02:00
setfacl -m user:www-data:rX $install_dir
setfacl -m user:www-data:rX $install_dir /seafile-server-$seafile_version
2022-11-02 17:19:55 +01:00
# At install time theses directory are not available
2023-11-23 17:07:30 +01:00
test -e $install_dir /seafile-server-$seafile_version /seahub && setfacl -m user:www-data:rX $install_dir /seafile-server-$seafile_version /seahub
test -e $install_dir /seafile-server-$seafile_version /seahub/media && setfacl -R -m user:www-data:rX $install_dir /seafile-server-$seafile_version /seahub/media
2024-04-21 15:20:12 +02:00
test -e $install_dir /seahub-data && setfacl -R -m user:www-data:rX $data_dir /seahub-data
2021-06-26 12:22:45 +02:00
2023-10-26 10:14:27 +02:00
find $data_dir \( \! -perm -o= \
2023-12-18 14:34:09 +01:00
-o \! -user $app \
-o \! -group $app \) \
-exec chown $app :$app { } \; \
2023-10-26 10:14:27 +02:00
-exec chmod o = { } \;
2019-06-11 22:28:26 +02:00
}
2023-09-27 19:21:58 +02:00
clean_url_in_db_config( ) {
sql_request = 'DELETE FROM `constance_config` WHERE `constance_key`= "SERVICE_URL"'
ynh_mysql_execute_as_root --sql " $sql_request " --database seahubdb
sql_request = 'DELETE FROM `constance_config` WHERE `constance_key`= "FILE_SERVER_ROOT"'
ynh_mysql_execute_as_root --sql " $sql_request " --database seahubdb
}