1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yourls_ynh.git synced 2024-09-03 20:35:59 +02:00

Added update,backup,restore,check_process and license; changed the yourl to in install script

This commit is contained in:
Anmol 2017-07-16 16:21:05 +05:30
parent af92722962
commit 0ed4257499
6 changed files with 280 additions and 1 deletions

25
LICENSE Normal file
View file

@ -0,0 +1,25 @@
__ ______ _ _ _____ _ _____
\ \ / / __ \| | | | __ \| | / ____|
\ \_/ / | | | | | | |__) | | | (___
\ /| | | | | | | _ /| | \___ \
| | | |__| | |__| | | \ \| |____ ____) |
|_| \____/ \____/|_| \_\______|_____/
YOURLS - Your Own URL Shortener
Copyright (c) 2009-2017 by the contributors
This program is free software. Do whatever the hell you want with it.
This program is distributed under the terms of the MIT license, in the hope that it will be useful and/or fun to use. There is absolutely no guarantee of any kind about anything.
Wherever third party code has been used, credit has been given in the code comments.
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

36
check_process Normal file
View file

@ -0,0 +1,36 @@
# See here for more informations
# https://github.com/YunoHost/package_check#syntax-check_process-file
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=0
setup_public=0
upgrade=1
backup_restore=1
multi_instance=0
incorrect_path=1
port_already_use=0
change_url=0
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
# Level 4:
Level 4=0
# Level 5:
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options
Email=anmol@datamol.in
Notification=none

55
scripts/backup Normal file
View file

@ -0,0 +1,55 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit on command errors and treat access to unset variables as an error
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory
sudo cp ../settings/scripts/_common.sh ./_common.sh
sudo chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
db_name=$(ynh_app_setting_get $app db_name)
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup "$final_path" "${backup_dir}$final_path"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${backup_dir}/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_mysql_dump_db "$db_name" > db.sql
ynh_backup "db.sql" "${backup_dir}/db.sql"

View file

@ -105,7 +105,7 @@ sudo chmod 600 $nginxconf
# Reload Nginx and regenerate SSOwat conf # Reload Nginx and regenerate SSOwat conf
sudo service nginx reload sudo service nginx reload
sudo yunohost app setting yourls unprotected_uris -v "/" sudo yunohost app setting $app unprotected_uris -v "/"
sudo yunohost app ssowatconf sudo yunohost app ssowatconf
# Start Yourls install (database table creation) # Start Yourls install (database table creation)

77
scripts/restore Normal file
View file

@ -0,0 +1,77 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit on command errors and treat access to unset variables as an error
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory
sudo cp ../settings/scripts/_common.sh ./_common.sh
sudo chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_restore_file "$final_path"
sudo chown -R www-data: $final_path
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
ynh_mysql_setup_db $db_name $db_name $db_pwd
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
sudo yunohost app setting $app unprotected_uris -v "/"
sudo systemctl reload php5-fpm
sudo systemctl reload nginx

86
scripts/upgrade Normal file
View file

@ -0,0 +1,86 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get $app admin)
final_path=$(ynh_app_setting_get $app final_path)
db_name=$(ynh_app_setting_get $app db_name)
if [ -z $db_name ]; then # If db_name doesn't exist, create it
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
fi
#=================================================
# CHECK THE PATH
#=================================================
# Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
sudo mv ${final_path} ${final_path}.old
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
sudo cp -a ${final_path}.old/index.php ${final_path}
sudo cp -a ${final_path}.old/user/plugins/yunohost_auth ${final_path}/user/plugins
sudo cp -a ${final_path}.old/.htaccess ${final_path}
sudo cp -a ${final_path}.old/user/config.php ${final_path}/user
sudo chown -R www-data: $final_path
# delete temp directory
sudo rm -Rf ${final_path}.old
#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@LOCATIONTOCHANGE@$path_url@g" ../conf/nginx.conf*
sed -i "s@PATHTOCHANGE@${path_url%/}@g" ../conf/nginx.conf*
sed -i "s@DOMAINTOCHANGE@$domain@g" ../conf/nginx.conf*
sed -i "s@ALIASTOCHANGE@$final_path@g" ../conf/nginx.conf*
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
sudo cp ../conf/nginx.conf $nginxconf
sudo chown root: $nginxconf
sudo chmod 600 $nginxconf
#=================================================
# SETUP SSOWAT
#=================================================
ynh_app_setting_set $app unprotected_uris "/"
#=================================================
# RELOAD NGINX
#=================================================
sudo systemctl reload nginx