1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/svgedit_ynh.git synced 2024-09-03 20:26:24 +02:00

Initial commit

This commit is contained in:
Luc Didry 2017-03-17 12:10:31 +01:00
commit a8e99fe739
11 changed files with 315 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*~
*.sw[op]

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2017 Framasoft
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.

24
README.md Normal file
View file

@ -0,0 +1,24 @@
# SVG Edit app for YunoHost
- [Yunohost project](https://yunohost.org)
- [SVG Edit app website](https://github.com/SVG-Edit/svgedit)
![alt text](https://svg-edit.github.io/svgedit/images/logo48x48.svg "svg-edit logo of a pencil") SVG-edit
===
SVG-edit is a fast, web-based, javascript-driven SVG drawing editor that works in any modern browser.
## Usage
- Copy this app before work on it.
- Edit `conf/nginx.conf` file to match application prerequisites.
- Edit `manifest.json` with application specific information.
- Edit the `install`, `upgrade`, `remove`, `backup`, and `restore` scripts.
- Add a `LICENSE` file for the package.
- Edit `README.md`.
**More information on the documentation page:**
https://yunohost.org/packaging_apps
**Upgrade this package:**
`sudo yunohost app upgrade --verbose example -u https://github.com/YunoHost-Apps/example_ynh`
**Multi-user:** Yes/No. How about the ldap and HTTP auth support.

2
conf/app.src Normal file
View file

@ -0,0 +1,2 @@
SOURCE_URL=https://github.com/SVG-Edit/svgedit/releases/download/svg-edit-2.8.1/svg-edit-2.8.1.zip
SOURCE_SUM=982687a16035944494c6be4f7c5e6972

11
conf/nginx.conf Normal file
View file

@ -0,0 +1,11 @@
location YNH_WWW_PATH {
# Path to source
alias YNH_WWW_ALIAS ;
# Example PHP configuration (remove if not used)
index svg-editor.html;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

55
manifest.json Normal file
View file

@ -0,0 +1,55 @@
{
"name": "SVG-edit",
"id": "svgedit",
"packaging_format": 1,
"description": {
"en": "SVG-edit is a fast, web-based, javascript-driven SVG drawing editor that works in any modern browser.",
"fr": "SVG-edit est un outil de manipulation de SVG en ligne, rapide, et écrit en javascript qui fonctionne avec tout navigateur moderne."
},
"url": "https://github.com/SVG-Edit/svgedit",
"license": "MIT",
"maintainer": {
"name": "Luc Didry",
"email": "luc@framasoft.org",
"url": "https://framasoft.org"
},
"requirements": {
"yunohost": ">> 2.4.0"
},
"multi_instance": true,
"services": [
"nginx"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for SVG-edit",
"fr": "Choisissez un nom de domaine pour SVG-edit"
},
"example": "domain.org"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for SVG-edit",
"fr": "Choisissez un chemin pour SVG-edit"
},
"example": "/svgedit",
"default": "/svgedit"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public application?",
"fr": "Est-ce une application publique ?"
},
"default": true
}
]
}
}

18
scripts/backup Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Backup sources & data
# Note: the last argument is where to save this path, see the restore script.
ynh_backup "/var/www/${app}" "sources"
# Copy NGINX configuration
domain=$(ynh_app_setting_get "$app" domain)
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"

70
scripts/install Executable file
View file

@ -0,0 +1,70 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# This is a multi-instance app, meaning it can be installed several times independently
# The id of the app as stated in the manifest is available as $YNH_APP_ID
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
# The app instance name is available as $YNH_APP_INSTANCE_NAME
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
# The app instance name is probably what you are interested the most, since this is
# guaranteed to be unique. This is a good unique identifier to define installation path,
# db names, ...
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Save app settings
ynh_app_setting_set "$app" is_public "$is_public"
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path_url}"
# Check needed packages
if ! ynh_package_is_installed "wget" ; then
apt-get install -y wget
fi
if ! ynh_package_is_installed "unzip" ; then
apt-get install -y unzip
fi
# Copy source files
src_path=/var/www/$app
sudo mkdir -p $src_path
mkdir ../sources/
cd ../sources/
wget -q https://github.com/SVG-Edit/svgedit/releases/download/svg-edit-2.8.1/svg-edit-2.8.1.zip
unzip svg-edit-2.8.1.zip
cd -
sudo cp -a ../sources/svg-edit-2.8.1/. $src_path
rm -rf ../sources/svg-edit-2.8.1/ ../sources/svg-edit-2.8.1.zip
touch $src_path/config.js $src_path/custom.css
# Set permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo chown -R root: $src_path
# Modify Nginx configuration file and copy it to Nginx conf directory
nginx_conf=../conf/nginx.conf
sed -i "s@YNH_WWW_PATH@$path_url@g" $nginx_conf
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
# If app is public, add url to SSOWat conf as skipped_uris
if [[ $is_public -eq 1 ]]; then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set "$app" unprotected_uris "/"
fi
# Reload services
sudo service nginx reload

19
scripts/remove Executable file
View file

@ -0,0 +1,19 @@
#!/bin/bash
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
# Remove sources
sudo rm -rf /var/www/$app
# Remove nginx configuration file
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
# Reload nginx service
sudo service nginx reload

35
scripts/restore Executable file
View file

@ -0,0 +1,35 @@
#!/bin/bash
# Note: each files and directories you've saved using the ynh_backup helper
# will be located in the current directory, regarding the last argument.
# Exit on command errors and treat unset variables as an error
set -eu
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Retrieve old app settings
domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_app_setting_get "$app" path_url)
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path_url}"
# Restore sources & data
src_path="/var/www/${app}"
sudo cp -a ./sources "$src_path"
# Restore permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo chown -R root: "$src_path"
# Restore NGINX configuration
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
# Restart webserver
sudo service nginx reload

58
scripts/upgrade Executable file
View file

@ -0,0 +1,58 @@
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_app_setting_get "$app" path)
is_public=$(ynh_app_setting_get "$app" is_public)
# Remove trailing "/" for next commands
path_url=${path_url%/}
# Check needed packages
if ! ynh_package_is_installed "wget" ; then
apt-get install -y wget
fi
if ! ynh_package_is_installed "unzip" ; then
apt-get install -y unzip
fi
# Copy source files
src_path=/var/www/$app
sudo mkdir -p $src_path
mkdir ../sources/
cd ../sources/
wget -q https://github.com/SVG-Edit/svgedit/releases/download/svg-edit-2.8.1/svg-edit-2.8.1.zip
unzip svg-edit-2.8.1.zip
cd -
sudo rm -rf $src_path/*
sudo cp -a ../sources/svg-edit-2.8.1/. $src_path
rm -rf ../sources/svg-edit-2.8.1/ ../sources/svg-edit-2.8.1.zip
touch $src_path/config.js $src_path/custom.css
# Set permissions to app files
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo chown -R root: $src_path
# Modify Nginx configuration file and copy it to Nginx conf directory
nginx_conf=../conf/nginx.conf
sed -i "s@YNH_WWW_PATH@$path_url@g" $nginx_conf
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
# If app is public, add url to SSOWat conf as skipped_uris
if [[ $is_public -eq 1 ]]; then
# See install script
ynh_app_setting_set "$app" unprotected_uris "/"
fi
# Reload nginx service
sudo service nginx reload