Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version updated with read-only mode if is public instance #20

Closed
wants to merge 15 commits into from
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Cesium package for YunoHost

[![Integration level](https://dash.yunohost.org/integration/cesium.svg)](https://dash.yunohost.org/appci/app/cesium) ![](https://ci-apps.yunohost.org/ci/badges/cesium.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cesium.maintain.svg)
[![Integration level](https://dash.yunohost.org/integration/cesium.svg)](https://dash.yunohost.org/appci/app/cesium) ![](https://ci-apps.yunohost.org/ci/badges/cesium.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cesium.maintain.svg)
[![Install Custom Webapp with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=cesium)


> *This package allow you to install Cesium quickly and simply on a YunoHost server.
> *This package allow you to install Cesium quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*

## Overview

[Cesium](https://cesium.app) is an [Unhosted webapp](https://unhosted.org) client for any [Duniter](https://duniter.org) crypto-currency.
It allows you to manage your wallet, certify your friends, and more !

**Shipped version:** v1.6.3
**Shipped version:** v1.6.7

## Links

Expand Down
20 changes: 13 additions & 7 deletions check_process
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
auto_remove=1
; Manifest
domain="domain.tld" (DOMAIN)
path="/cesium" (PATH)
path="/path" (PATH)
is_public=1 (PUBLIC|public=1|private=0)
; Checks
pkg_linter=1
Expand All @@ -14,10 +14,16 @@
upgrade=1
backup_restore=1
multi_instance=0
wrong_user=0
wrong_path=1
incorrect_path=1
corrupt_source=0
fail_download_source=0
port_already_use=0
final_path_already_use=0
change_url=1
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
Level 4=na
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
4 changes: 2 additions & 2 deletions conf/app.src
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/duniter/cesium/releases/download/v1.6.3/cesium-v1.6.3-web.zip
SOURCE_SUM=e6bb12bb56453781d01fe0f74afd28990d693010652b542eae0d3348f51d911e
SOURCE_URL=https://github.com/duniter/cesium/releases/download/v1.6.7/cesium-v1.6.7-web.zip
SOURCE_SUM=99157da53e42096c51ebf845c40c155cb1ed6d66678983c9947b528869b6284f
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=false
Expand Down
5 changes: 3 additions & 2 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
location YNH_WWW_PATH {
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {

# Path to source
alias YNH_WWW_ALIAS ;
alias __FINALPATH__/ ;

# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
Expand Down
22 changes: 11 additions & 11 deletions helper-update-version.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash
# Retrieve sources, get sha256sum, parse package version and update these strings in manifest, README and /conf/app.src

URL=$(curl -s https://api.github.com/repos/duniter/cesium/releases/latest | grep "browser_" | grep "web" | head -1 | cut -d\" -f4)
wget -nc --quiet $URL -P ./tmp
CHECKSUM=$(sha256sum ./tmp/cesium-*-web.zip | head -c 64)
sed -i "s/SOURCE_SUM=.*/SOURCE_SUM=${CHECKSUM}/" ./conf/app.src
sed -i "s#SOURCE_URL=.*#SOURCE_URL=$URL#" ./conf/app.src

VERSION=$(echo $URL | sed "s#https://github.com/duniter/cesium/releases/download/\(.*\)/cesium.*#\1#")
sed -i "s#\*\*Shipped version:\*\*.*#\*\*Shipped version:\*\* ${VERSION}#" ./README.md
sed -i "s# \"version\": \".*# \"version\": \"${VERSION}\~ynh1\",#" ./manifest.json
# URL=$(curl -s https://api.github.com/repos/duniter/cesium/releases/latest | grep "browser_" | grep "web" | head -1 | cut -d\" -f4)
# wget -nc --quiet $URL -P ./tmp
# CHECKSUM=$(sha256sum ./tmp/cesium-*-web.zip | head -c 64)
# sed -i "s/SOURCE_SUM=.*/SOURCE_SUM=${CHECKSUM}/" ./conf/app.src
# sed -i "s#SOURCE_URL=.*#SOURCE_URL=$URL#" ./conf/app.src

rm -f -R ./tmp
# VERSION=$(echo $URL | sed "s#https://github.com/duniter/cesium/releases/download/\(.*\)/cesium.*#\1#")
# sed -i "s#\*\*Shipped version:\*\*.*#\*\*Shipped version:\*\* ${VERSION}#" ./README.md
# sed -i "s# \"version\": \".*# \"version\": \"${VERSION}\~ynh1\",#" ./manifest.json

git commit README.md manifest.json conf/app.src -m "$VERSION"
M5oul marked this conversation as resolved.
Show resolved Hide resolved
# rm -f -R ./tmp

# git commit README.md manifest.json conf/app.src -m "$VERSION"
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"en": "Duniter client to manage wallets, certifications in a libre money.",
"fr": "Client Duniter pour gérer ses portes-monnaie, les certifications au sein d’une monnaie libre."
},
"version": "v1.6.3~ynh1",
"version": "v1.6.7~ynh1",
"url": "https://github.com/duniter/cesium",
"license": "AGPL-3.0-or-later",
"maintainer": {
Expand All @@ -15,7 +15,7 @@
"url": "https://moul.re"
},
"requirements": {
"yunohost": ">> 2.4.0"
"yunohost": ">> 3.7.0"
},
"multi_instance": false,
"services": [
Expand Down
64 changes: 53 additions & 11 deletions scripts/backup
Original file line number Diff line number Diff line change
@@ -1,18 +1,60 @@
#!/bin/bash

# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source /usr/share/yunohost/helpers

#=================================================
# MANAGE SCRIPT FAILURE
#=================================================

ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors

#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."

# See comments in install script
app=$YNH_APP_INSTANCE_NAME

# Source YunoHost helpers
source /usr/share/yunohost/helpers
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)

#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."

### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
### to be backuped and not an actual copy of any file. The actual backup that
### creates and fill the archive with the files happens in the core after this
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.

#=================================================
# BACKUP THE APP MAIN DIR
#=================================================

ynh_backup --src_path="$final_path"

#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================

ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"

#=================================================
# END OF SCRIPT
#=================================================

ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

# 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"
92 changes: 92 additions & 0 deletions scripts/change_url
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

source /usr/share/yunohost/helpers

#=================================================
# RETRIEVE ARGUMENTS
#=================================================

old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH

new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH

app=$YNH_APP_INSTANCE_NAME

#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."

# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)


#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================

change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi

change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi

#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating nginx web server configuration..."

nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf

# Change the path in the nginx config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
ynh_add_nginx_config
fi


# Change the domain for nginx
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi



#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..."

ynh_systemd_action --service_name=nginx --action=reload

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression --message="Change of URL completed for $app" --time --last

Loading