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

Allow subpath installation

This commit is contained in:
Maniack Crudelis 2017-11-05 18:40:37 +01:00
parent 4e4abe7715
commit a98b6c7de6
5 changed files with 123 additions and 37 deletions

View file

@ -1,15 +1,17 @@
;; Test complet avec libreoffice ;; Test complet avec libreoffice sans mypads
auto_remove=1 auto_remove=1
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER) admin="john" (USER)
password="password" password="password"
language="en" language="en"
is_public=1 (PUBLIC|public=1|private=0) is_public=1 (PUBLIC|public=1|private=0)
export="libreoffice" export="libreoffice"
mypads=0
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=0 setup_sub_dir=1
setup_root=1 setup_root=1
setup_nourl=0 setup_nourl=0
setup_private=1 setup_private=1
@ -17,29 +19,48 @@
upgrade=1 upgrade=1
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
incorrect_path=0 incorrect_path=1
port_already_use=1 (9001) port_already_use=1 (9001)
change_url=0 change_url=0
;; Test avec mypads
auto_remove=1
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
password="password"
language="en"
is_public=1 (PUBLIC|public=1|private=0)
export="libreoffice"
mypads=1
; Checks
setup_root=1
upgrade=1
backup_restore=1
;; Test abiword ;; Test abiword
auto_remove=1 auto_remove=1
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER) admin="john" (USER)
password="password" password="password"
language="en" language="en"
is_public=1 (PUBLIC|public=1|private=0) is_public=1 (PUBLIC|public=1|private=0)
export="abiword" export="abiword"
mypads=1
; Checks ; Checks
setup_root=1 setup_root=1
;; Test sans export ;; Test sans export
auto_remove=1 auto_remove=1
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER) admin="john" (USER)
password="password" password="password"
language="en" language="en"
is_public=1 (PUBLIC|public=1|private=0) is_public=1 (PUBLIC|public=1|private=0)
export="none" export="none"
mypads=1
; Checks ; Checks
setup_root=1 setup_root=1
;;; Levels ;;; Levels

View file

@ -1,7 +1,9 @@
location / { location __PATH__/ {
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
#sub_path_only rewrite ^__PATH__/admin$ __PATH__/admin/ permanent;
proxy_pass http://127.0.0.1:__PORT__/; proxy_pass http://127.0.0.1:__PORT__/;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_buffering off; proxy_buffering off;
@ -10,6 +12,6 @@ location / {
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }
location ~* /p/[^/]*(_|%|\*)[^/]*/export/etherpad { location ~* __PATH__/p/[^/]*(_|%|\*)[^/]*/export/etherpad {
return 404; return 404;
} }

View file

@ -32,6 +32,20 @@
}, },
"example": "sub.domain.org" "example": "sub.domain.org"
}, },
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Etherpad",
"fr": "Choisissez un chemin pour Etherpad"
},
"help": {
"en": "If you choose to install mypads plugin, etherpad has to be on /",
"fr": "Si vous choisissez d'installer le plugin mypads, etherpad doit être sur /"
},
"example": "/",
"default": "/"
},
{ {
"name": "admin", "name": "admin",
"type": "user", "type": "user",
@ -76,6 +90,18 @@
}, },
"choices" : ["none", "abiword", "libreoffice"], "choices" : ["none", "abiword", "libreoffice"],
"default" : "none" "default" : "none"
},
{
"name": "mypads",
"type": "boolean",
"ask": {
"en": "Do you want to install mypads plugin ?",
"fr": "Voulez-vous installer le plugin mypads ?"
},
"help": {
"en": "<a href=https://git.framasoft.org/framasoft/ep_mypads target=_blank>mypads plugin</a>"
},
"default": true
} }
] ]
} }

View file

@ -31,11 +31,13 @@ ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est dét
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
export=$YNH_APP_ARG_EXPORT export=$YNH_APP_ARG_EXPORT
mypads=$YNH_APP_ARG_MYPADS
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -48,34 +50,31 @@ then
ynh_die "The password must be between 8 and 30 characters." ynh_die "The password must be between 8 and 30 characters."
fi fi
if yunohost domain list | grep -q $domain # Vérifie la liste des domaines if [ "$path_url" != "/" ] && [ $mypads -eq 1 ]
then # Si le domaine existe dans Yunohost then
if yunohost app map | grep -q $domain # Vérifie la liste des apps par domaine ynh_die "Mypads needs to be installed on the root of a domain or a subdomain."
then # Si une app est installée sur ce domaine.
WARNING echo "An app is already installed on the domain $domain. Mypads needs a whole domain or subdomain to himself."
fi
fi fi
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die "This path already contains a folder"
path_url="/"
# Check web path availability # Check web path availability
ynh_webpath_available $domain $path_url ynh_webpath_available $domain $path_url
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register $app $domain $path_url
path_url="" # Assure la compatibilité avec les fonctions utilisant $path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_app_setting_set $app domain $domain ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app admin $admin ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app password $password ynh_app_setting_set $app password $password
ynh_app_setting_set $app language $language ynh_app_setting_set $app language $language
ynh_app_setting_set $app export $export ynh_app_setting_set $app export $export
ynh_app_setting_set $app mypads $mypads
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -121,6 +120,11 @@ ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie d
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
if [ "$path_url" != "/" ]
then
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
fi
ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf"
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
@ -217,7 +221,9 @@ npm install ep_delete_empty_pads >> $install_log 2>&1 # Framapad - Delete pads w
npm install ep_font_color >> $install_log 2>&1 # Framapad - Apply colors to fonts npm install ep_font_color >> $install_log 2>&1 # Framapad - Apply colors to fonts
npm install ep_headings2 >> $install_log 2>&1 # Framapad - Adds heading support to Etherpad Lite. npm install ep_headings2 >> $install_log 2>&1 # Framapad - Adds heading support to Etherpad Lite.
npm install ep_markdown >> $install_log 2>&1 # Framapad - Edit and Export as Markdown in Etherpad npm install ep_markdown >> $install_log 2>&1 # Framapad - Edit and Export as Markdown in Etherpad
npm install ep_mypads >> $install_log 2>&1 # Framapad - Groups and private pads for etherpad if [ $mypads -eq 1 ]; then
npm install ep_mypads >> $install_log 2>&1 # Framapad - Groups and private pads for etherpad
fi
npm install ep_page_view >> $install_log 2>&1 # Framapad - Add support to do 'page view', with a toggle on/off option in Settings, also Page Breaks with Control Enter npm install ep_page_view >> $install_log 2>&1 # Framapad - Add support to do 'page view', with a toggle on/off option in Settings, also Page Breaks with Control Enter
npm install ep_spellcheck >> $install_log 2>&1 # Framapad - Add support to do 'Spell checking' npm install ep_spellcheck >> $install_log 2>&1 # Framapad - Add support to do 'Spell checking'
npm install ep_subscript_and_superscript >> $install_log 2>&1 # Framapad - Add support for Subscript and Superscript npm install ep_subscript_and_superscript >> $install_log 2>&1 # Framapad - Add support for Subscript and Superscript
@ -229,15 +235,18 @@ chown -R $app: $final_path/node_modules
# SOME HACKS # SOME HACKS
#================================================= #=================================================
# Ajoute un lien vers etherpad pour créer des pads anonymes depuis Mypads. if [ $mypads -eq 1 ]
ynh_replace_string "^ *\"DESCRIPTION\": .*</ul>" "&<a href=../>Pads anonymes</a>" $final_path/node_modules/ep_mypads/static/l10n/fr.json then
ynh_replace_string "^ *\"DESCRIPTION\": .*</ul>" "&<a href=../>Anonymous pads</a>" $final_path/node_modules/ep_mypads/static/l10n/en.json # Ajoute un lien vers etherpad pour créer des pads anonymes depuis Mypads.
# Et un lien vers l'admin etherpad depuis Mypads. ynh_replace_string "^ *\"DESCRIPTION\": .*</ul>" "&<a href=../>Pads anonymes</a>" $final_path/node_modules/ep_mypads/static/l10n/fr.json
ynh_replace_string "^ *\"FOOTER\": .*2.0" "& | <a href='../admin'>Etherpad admin</a>" $final_path/node_modules/ep_mypads/static/l10n/en.json ynh_replace_string "^ *\"DESCRIPTION\": .*</ul>" "&<a href=../>Anonymous pads</a>" $final_path/node_modules/ep_mypads/static/l10n/en.json
ynh_replace_string "^ *\"FOOTER\": .*2.0" "& | <a href='../admin'>Etherpad admin</a>" $final_path/node_modules/ep_mypads/static/l10n/fr.json # Et un lien vers l'admin etherpad depuis Mypads.
ynh_replace_string "^ *\"FOOTER\": .*2.0" "& | <a href='../admin'>Etherpad admin</a>" $final_path/node_modules/ep_mypads/static/l10n/en.json
ynh_replace_string "^ *\"FOOTER\": .*2.0" "& | <a href='../admin'>Etherpad admin</a>" $final_path/node_modules/ep_mypads/static/l10n/fr.json
mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad. mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad.
sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads">Mypads</a></font></center>@" $final_path/src/templates/index.html # Pour ajouter un lien vers le plugin mypads depuis la page d'Etherpad. sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads">Mypads</a></font></center>@" $final_path/src/templates/index.html # Pour ajouter un lien vers le plugin mypads depuis la page d'Etherpad.
fi
#================================================= #=================================================
# START ETHERPAD IN BACKGROUND # START ETHERPAD IN BACKGROUND
@ -269,9 +278,16 @@ systemctl reload nginx
# CHECK ETHERPAD STARTING # CHECK ETHERPAD STARTING
#================================================= #=================================================
lang_OK=0 if [ $mypads -eq 1 ]
then
lang_OK=0
else
lang_OK=1
fi
for i in `seq 1 120` for i in `seq 1 120`
do # La boucle attend le démarrage d'etherpad. Ou 2 minutes. Cette boucle évite simplement un 502 au début, car le démarrage est long... do # La boucle attend le démarrage d'etherpad. Ou 2 minutes. Cette boucle évite simplement un 502 au début, car le démarrage est long...
if [ $mypads -eq 1 ]
then
if grep -q "You can access your Etherpad instance at" "$tempfile" && [ "$lang_OK" -eq 0 ] ; then if grep -q "You can access your Etherpad instance at" "$tempfile" && [ "$lang_OK" -eq 0 ] ; then
# Si le log annonce une première fois le démarrage d'etherpad, applique la langue de mypads et redémarre le service. # Si le log annonce une première fois le démarrage d'etherpad, applique la langue de mypads et redémarre le service.
WARNING echo "Le service $app a démarré correctement." WARNING echo "Le service $app a démarré correctement."
@ -283,6 +299,7 @@ do # La boucle attend le démarrage d'etherpad. Ou 2 minutes. Cette boucle évit
lang_OK=1 lang_OK=1
i=1; i=1;
fi fi
fi
if grep -q "You can access your Etherpad instance at" "$tempfile" && [ "$lang_OK" -eq 1 ]; then if grep -q "You can access your Etherpad instance at" "$tempfile" && [ "$lang_OK" -eq 1 ]; then
WARNING echo "Le service $app a démarré correctement." WARNING echo "Le service $app a démarré correctement."
break # Si le log annonce une deuxième fois le démarrage d'etherpad, sort de la boucle. break # Si le log annonce une deuxième fois le démarrage d'etherpad, sort de la boucle.

View file

@ -18,6 +18,7 @@ source _variables
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get $app admin) admin=$(ynh_app_setting_get $app admin)
language=$(ynh_app_setting_get $app language) language=$(ynh_app_setting_get $app language)
is_public=$(ynh_app_setting_get $app is_public) is_public=$(ynh_app_setting_get $app is_public)
@ -25,6 +26,7 @@ final_path=$(ynh_app_setting_get $app final_path)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get $app port)
export=$(ynh_app_setting_get $app export) export=$(ynh_app_setting_get $app export)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get $app db_name)
mypads=$(ynh_app_setting_get $app mypads)
#================================================= #=================================================
# FIX OLD THINGS # FIX OLD THINGS
@ -61,6 +63,16 @@ if [ -z $export ]; then # Si export n'est pas renseigné dans app setting
ynh_app_setting_set $app export $export ynh_app_setting_set $app export $export
fi fi
if [ -z $mypads ]; then # Si mypads n'est pas renseigné dans app setting
mypads=1
ynh_app_setting_set $app mypads $mypads
fi
if [ -z $path_url ]; then # Si path_url n'est pas renseigné dans app setting
path_url="/"
ynh_app_setting_set $app path $path_url
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
@ -92,6 +104,11 @@ ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie d
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
if [ "$path_url" != "/" ]
then
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
fi
ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf"
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
@ -185,8 +202,11 @@ ynh_add_systemd_config
# SOME HACKS # SOME HACKS
#================================================= #=================================================
mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad. if [ $mypads -eq 1 ]
sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads">Mypads</a></font></center>@" $final_path/src/templates/index.html # Pour ajouter un lien vers le plugin mypads depuis la page d'Etherpad. then
mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad.
sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads">Mypads</a></font></center>@" $final_path/src/templates/index.html # Pour ajouter un lien vers le plugin mypads depuis la page d'Etherpad.
fi
#================================================= #=================================================
# START ETHERPAD IN BACKGROUND # START ETHERPAD IN BACKGROUND