1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/calibreweb_ynh.git synced 2024-09-03 18:16:20 +02:00

Install script w/ all options

This commit is contained in:
Krakinou 2018-12-12 22:06:24 +01:00
parent edee529169
commit f15efd1ba2
6 changed files with 50 additions and 85 deletions

View file

@ -0,0 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Permet de générer le hash pour le password
import sys
path=sys.argv[2]
sys.path.append(path)
from werkzeug.security import generate_password_hash
password=sys.argv[1]
print generate_password_hash(password)

View file

@ -1,5 +1,5 @@
location __PATH__ { location __PATH__ {
client_max_body_size 20M;
# Force usage of https # Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=calibreweb Description=__APP__
After=network.target After=network.target
[Service] [Service]
@ -7,7 +7,7 @@ Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__FINALPATH__/
ExecStart=/usr/bin/python __FINALPATH__/cps.py ExecStart=/bin/sh -c '/usr/bin/python __FINALPATH__/cps.py >> /var/log/__APP__/__APP__.log 2>&1'
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -41,6 +41,18 @@
"example": "/calibre", "example": "/calibre",
"default": "/calibre" "default": "/calibre"
}, },
{
"name": "calibre_path",
"ask": {
"en": "Select the folder containing the library",
"fr": "Choisissez le répertoire contenant la bibliothèque"
},
"help": {
"en": "This folder should have read write access. It will be created if it does not exist.",
"fr": "Le répertoire doit être accesible en lecture écriture, il sera créé s'il n'existe pas.."
},
"example": "/home/johndoe/calibre"
},
{ {
"name": "admin", "name": "admin",
"type": "user", "type": "user",
@ -50,6 +62,15 @@
}, },
"example": "johndoe" "example": "johndoe"
}, },
{
"name": "language",
"ask": {
"en": "Select a default language (you may change it later in the app",
"fr": "Choisissez une langue par défaur (vous pourre la changer ultérieurement dans l'application"
},
"choices": [ "fr", "en", "es", "de"],
"default": "fr"
},
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",

View file

@ -1,13 +1,4 @@
#!/bin/bash #!/bin/bash
# ============= FUTURE YUNOHOST HELPER ============= pkg_dependencies="sqlite3"
# Delete a file checksum from the app settings
#
# $app should be defined when calling this helper
#
# usage: ynh_remove_file_checksum file
# | arg: file - The file for which the checksum will be deleted
ynh_delete_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name
}

View file

@ -27,6 +27,8 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
#language=$YNH_APP_ARG_LANGUAGE #language=$YNH_APP_ARG_LANGUAGE
#password=$YNH_APP_ARG_PASSWORD #password=$YNH_APP_ARG_PASSWORD
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
calibre_dir=$3
lang=$5
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
@ -60,11 +62,6 @@ ynh_app_setting_set $app is_public $is_public
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
### Use these lines if you have to open a port for the application
### `ynh_find_port` will find the first available port starting from the given port.
### If you're not using these lines:
### - Remove the section "CLOSE A PORT" in the remove script
# Find a free port # Find a free port
port=$(ynh_find_port 8083) port=$(ynh_find_port 8083)
# Open this port # Open this port
@ -75,10 +72,6 @@ ynh_app_setting_set $app port $port
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" ynh_setup_source "$final_path"
@ -88,24 +81,14 @@ ynh_setup_source "$final_path"
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. ynh_install_app_dependencies $pkg_dependencies
### Those deb packages will be installed as dependencies of this package.
### If you're not using this helper:
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
#ynh_install_app_dependencies deb1 deb2
pip install --target $final_path/vendor -r $final_path/requirements.txt pip install --target $final_path/vendor -r $final_path/requirements.txt
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
@ -120,48 +103,21 @@ ynh_system_user_create $app
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
# ... # SET SQLITE DATABASE SETTINGS
#================================================= #=================================================
sqlite3 $final_path/app.db "UPDATE settings SET config_calibre_dir=\"$calibre_path\" WHERE ID=1"
sqlite3 $final_path/app.db "UPDATE settings SET config_port=$port WHERE ID=1"
sqlite3 $final_path/app.db "UPDATE user SET nickname=\"$admin\" WHERE ID=1"
sqlite3 $final_path/app.db "UPDATE user SET default_language=\"$lang\" WHERE ID=1"
sqlite3 $final_path/app.db "UPDATE user SET password='$(python ../conf/generate_password_hash.py $password $final_path/vendor)' WHERE ID=1"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
### `ynh_systemd_config` is used to configure a systemd script for an app.
### It can be used for apps that use sysvinit (with adaptation) or systemd.
### Have a look at the app to be sure this app needs a systemd script.
### `ynh_systemd_config` will use the file conf/systemd.service
### If you're not using these lines:
### - You can remove those files in conf/.
### - Remove the section "BACKUP SYSTEMD" in the backup script
### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script
### - As well as the section "RESTORE SYSTEMD" in the restore script
### - And the section "SETUP SYSTEMD" in the upgrade script
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
### `ynh_replace_string` is used to replace a string in a file.
### (It's compatible with sed regular expressions syntax)
#ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
### `ynh_store_file_checksum` is used to store the checksum of a file.
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
### you can make a backup of this file before modifying it again if the admin had modified it.
# Calculate and store the config file checksum into the app settings
#ynh_store_file_checksum "$final_path/CONFIG_FILE"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -173,36 +129,23 @@ ynh_add_systemd_config
### that really need such authorization. ### that really need such authorization.
# Set permissions to app files # Set permissions to app files
chown -R root: $final_path chown -R $app:$app $final_path
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
### Use this helper only if there is effectively a log file for this app.
### If you're not using this helper:
### - Remove the section "BACKUP LOGROTATE" in the backup script
### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script
### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script
### - And the section "SETUP LOGROTATE" in the upgrade script
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_use_logrotate
chown -R $app:$app /var/log/$app
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
### `yunohost service add` is a CLI yunohost command to add a service in the admin panel. yunohost service add $app --log "/var/log/$app/$app.log"
### You'll find the service in the 'services' section of YunoHost admin panel.
### This CLI command would be useless if the app does not have any services (systemd or sysvinit)
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
### - As well as the section ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
#yunohost service add NAME_INIT.D --log "/var/log/FILE.log"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
@ -220,3 +163,4 @@ fi
#================================================= #=================================================
systemctl reload nginx systemctl reload nginx
systemctl start $app