mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
Many Fix and set /opt as default install dir
This commit is contained in:
parent
0fdafb9aa7
commit
58ad4dfef9
7 changed files with 78 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -222,3 +222,5 @@ pip-log.txt
|
|||
.kateproject
|
||||
.kateproject.d
|
||||
.directory
|
||||
*-swp
|
||||
|
||||
|
|
|
@ -56,7 +56,9 @@ This package is published under MIT License
|
|||
Use a special user and put seafile binary in /opt dir :
|
||||
--------------------------------------
|
||||
|
||||
With this new package for a better security, it's possible to run seafile with a special user (seafile) put all seafile file in /opt/yunohost dir.
|
||||
~~With this new package for a better security, it's possible to run seafile with a special user (seafile) put all seafile file in /opt/yunohost dir.~~
|
||||
In the new package version the install is by default in /opt dir, so it section is only usefull for user how as already installed seafile.
|
||||
|
||||
To do this open a console and do this command :
|
||||
|
||||
```
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
location PATHTOCHANGE1 {
|
||||
if ($scheme = 'http' ) {
|
||||
return 301 https://$http_host/seafile/;
|
||||
}
|
||||
proxy_pass http://127.0.0.1:SEAHUB_PORT;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
|
|
@ -122,3 +122,61 @@ ynh_clean_setup () {
|
|||
pkill -f ccnet-server
|
||||
pkill -f "seahub"
|
||||
}
|
||||
|
||||
|
||||
# Implement PR : https://github.com/YunoHost/yunohost/pull/392
|
||||
|
||||
# Use logrotate to manage the logfile
|
||||
#
|
||||
# usage: ynh_use_logrotate [logfile] [--non-append]
|
||||
# | arg: logfile - absolute path of logfile
|
||||
# | option: --non-append - Replace the config file instead of appending this new config.
|
||||
#
|
||||
# If no argument provided, a standard directory will be use. /var/log/${app}
|
||||
# You can provide a path with the directory only or with the logfile.
|
||||
# /parentdir/logdir
|
||||
# /parentdir/logdir/logfile.log
|
||||
#
|
||||
# It's possible to use this helper several times, each config will be added to the same logrotate config file.
|
||||
# Unless you use the option --non-append
|
||||
ynh_use_logrotate () {
|
||||
local customtee="tee -a"
|
||||
if [ $# -gt 0 ] && [ "$1" == "--non-append" ]; then
|
||||
customtee="tee"
|
||||
# Destroy this argument for the next command.
|
||||
shift
|
||||
elif [ $# -gt 1 ] && [ "$2" == "--non-append" ]; then
|
||||
customtee="tee"
|
||||
fi
|
||||
if [ $# -gt 0 ]; then
|
||||
if [ "$(echo ${1##*.})" == "log" ]; then # Keep only the extension to check if it's a logfile
|
||||
logfile=$1 # In this case, focus logrotate on the logfile
|
||||
else
|
||||
logfile=$1/*.log # Else, uses the directory and all logfile into it.
|
||||
fi
|
||||
else
|
||||
logfile="/var/log/${app}/*.log" # Without argument, use a defaut directory in /var/log
|
||||
fi
|
||||
cat > ./${app}-logrotate << EOF # Build a config file for logrotate
|
||||
$logfile {
|
||||
# Rotate if the logfile exceeds 100Mo
|
||||
size 100M
|
||||
# Keep 12 old log maximum
|
||||
rotate 12
|
||||
# Compress the logs with gzip
|
||||
compress
|
||||
# Compress the log at the next cycle. So keep always 2 non compressed logs
|
||||
delaycompress
|
||||
# Copy and truncate the log to allow to continue write on it. Instead of move the log.
|
||||
copytruncate
|
||||
# Do not do an error if the log is missing
|
||||
missingok
|
||||
# Not rotate if the log is empty
|
||||
notifempty
|
||||
# Keep old logs in the same dir
|
||||
noolddir
|
||||
}
|
||||
EOF
|
||||
sudo mkdir -p $(dirname "$logfile") # Create the log directory, if not exist
|
||||
cat ${app}-logrotate | sudo $customtee /etc/logrotate.d/$app > /dev/null # Append this config to the existing config file, or replace the whole config file (depending on $customtee)
|
||||
}
|
||||
|
|
|
@ -17,16 +17,16 @@ admin=$YNH_APP_ARG_ADMIN
|
|||
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
|
||||
is_public=$YNH_APP_ARG_PUBLIC_SITE
|
||||
seafile_data=/home/yunohost.app/seafile-data
|
||||
final_path=/var/www/$app
|
||||
seafile_user=www-data
|
||||
final_path=/opt/yunohost/$app
|
||||
seafile_user=seafile
|
||||
|
||||
# Create special path with / at the end
|
||||
set_path_2
|
||||
|
||||
# Check domain/path availability
|
||||
test $(ynh_webpath_available $domain $path) == 'True' || ynh_die "$domain$path is not available, please use an other domain or path."
|
||||
ynh_webpath_register $app $domain $path
|
||||
|
||||
# Create special path with / at the end
|
||||
set_path_2
|
||||
|
||||
# Check Final Path availability
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
|
@ -87,6 +87,7 @@ echo 'MEDIA_URL = "'$path2'media/"' | tee -a $final_path/conf/seahub_settings.py
|
|||
echo 'COMPRESS_URL = MEDIA_URL' | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "STATIC_URL = MEDIA_URL + 'assets/'" | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "LOGIN_URL = '"$path2"accounts/login/'" | tee -a $final_path/conf/seahub_settings.py
|
||||
echo "ALLOWED_HOSTS = ['"$domain"']" | tee -a $final_path/conf/seahub_settings.py
|
||||
|
||||
# Email configuration
|
||||
echo 'EMAIL_USE_TLS = False' | tee -a $final_path/conf/seahub_settings.py
|
||||
|
@ -153,8 +154,7 @@ else
|
|||
fi
|
||||
|
||||
# Add logrotate
|
||||
ynh_use_logrotate $final_path/logs/seaf-server.log
|
||||
ynh_use_logrotate $final_path/logs/ccnet.log
|
||||
ynh_use_logrotate $final_path/logs
|
||||
|
||||
# register yunohost service
|
||||
yunohost service add seafile-server
|
||||
|
|
|
@ -16,8 +16,6 @@ get_configuration
|
|||
domain=$(ynh_app_setting_get $app domain)
|
||||
path=$(ynh_normalize_url_path $(ynh_app_setting_get $app path))
|
||||
db_pwd=$(ynh_app_setting_get ${app} mysqlpwd)
|
||||
final_path=/var/www/$app
|
||||
seafile_user=www-data
|
||||
|
||||
# Check domain/path availability
|
||||
ynh_webpath_available $domain $path || ynh_die "$domain/$path is not available, please use an other domain or path."
|
||||
|
@ -28,6 +26,9 @@ install_dependance
|
|||
# Restore all config and data
|
||||
ynh_restore
|
||||
|
||||
# Get configuration for user and final path
|
||||
get_configuration
|
||||
|
||||
# Restore mysql dump
|
||||
dbuser=seafile
|
||||
ynh_mysql_create_db ccnetdb "$dbuser" "$db_pwd"
|
||||
|
@ -41,8 +42,7 @@ su -c "mysql -u ${app} -p$db_pwd seahubdb < ${YNH_CWD}/seahubdb.dmp"
|
|||
python $final_path/add_sso_conf.py
|
||||
|
||||
# Add logrotate
|
||||
ynh_use_logrotate $final_path/logs/seaf-server.log
|
||||
ynh_use_logrotate $final_path/logs/ccnet.log
|
||||
ynh_use_logrotate $final_path/logs
|
||||
|
||||
# Add Seafile to YunoHost's monitored services
|
||||
yunohost service add seafile-server
|
||||
|
|
|
@ -70,7 +70,7 @@ case $installed_version in
|
|||
../conf/upgrade_6.0.exp $final_path/seafile-server-$seafile_version $root_pwd
|
||||
;&
|
||||
"6.0."* )
|
||||
python ../conf/update_sso_conf.py
|
||||
python ../conf/update_sso_conf.py || true
|
||||
install_dependance
|
||||
|
||||
# Update seafile by script
|
||||
|
|
Loading…
Reference in a new issue