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

Merge pull request #56 from YunoHost-Apps/testing

Testing
This commit is contained in:
Tagada 2023-06-27 19:49:33 +02:00 committed by GitHub
commit 257a2fa890
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 167 additions and 766 deletions

View file

@ -1,137 +0,0 @@
#!/bin/bash
#=================================================
# PACKAGE UPDATING HELPER
#=================================================
# This script is meant to be run by GitHub Actions
# The YunoHost-Apps organisation offers a template Action to run this script periodically
# Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected.
#=================================================
# FETCHING LATEST RELEASE AND ITS ASSETS
#=================================================
# Fetching information
current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'"))
# Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out.
# You may need more tweaks here if the upstream repository has different naming conventions.
if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
version=${version:1}
fi
# Setting up the environment variables
echo "Current version: $current_version"
echo "Latest release from upstream: $version"
echo "VERSION=$version" >> $GITHUB_ENV
# For the time being, let's assume the script will fail
echo "PROCEED=false" >> $GITHUB_ENV
# Proceed only if the retrieved version is greater than the current one
if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then
echo "::warning ::No new version available"
exit 0
# Proceed only if a PR for this new version does not already exist
elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then
echo "::warning ::A branch already exists for this update"
exit 0
fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)"
#=================================================
# UPDATE SOURCE FILES
#=================================================
# Here we use the $assets variable to get the resources published in the upstream release.
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like.
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory
# Here we base the source file name upon a unique keyword in the assets url (arch)
# Leave $src empty to ignore the asset
case $asset_url in
*"linux-amd64.tar.gz")
src="amd64"
;;
*"linux-arm64.tar.gz")
src="arm64"
;;
*"linux-armv7l.tar.gz")
src="armhf"
;;
*)
src=""
;;
esac
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
# Create the temporary directory
tempdir="$(mktemp -d)"
# Download sources and calculate checksum
filename=${asset_url##*/}
curl --silent -4 -L $asset_url -o "$tempdir/$filename"
checksum=$(sha256sum "$tempdir/$filename" | head -c 64)
# Delete temporary directory
rm -rf $tempdir
# Get extension
if [[ $filename == *.tar.gz ]]; then
extension=tar.gz
else
extension=${filename##*.}
fi
# Rewrite source file
cat <<EOT > conf/$src.src
SOURCE_URL=$asset_url
SOURCE_SUM=$checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true
EOT
echo "... conf/$src.src updated"
else
echo "... asset ignored"
fi
done
#=================================================
# SPECIFIC UPDATE STEPS
#=================================================
# Any action on the app's source code can be done.
# The GitHub Action workflow takes care of committing all changes after this script ends.
#=================================================
# GENERIC FINALIZATION
#=================================================
# Replace new version in manifest
echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json
# No need to update the README, yunohost-bot takes care of it
# The Action will proceed only if the PROCEED environment variable is set to true
echo "PROCEED=true" >> $GITHUB_ENV
exit 0

View file

@ -1,49 +0,0 @@
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
# This file should be enough by itself, but feel free to tune it to your needs.
# It calls updater.sh, which is where you should put the app-specific update steps.
name: Check for new upstream releases
on:
# Allow to manually trigger the workflow
workflow_dispatch:
# Run it every day at 6:00 UTC
schedule:
- cron: '0 6 * * *'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- name: Fetch the source code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the updater script
id: run_updater
run: |
# Setting up Git user
git config --global user.name 'yunohost-bot'
git config --global user.email 'yunohost-bot@users.noreply.github.com'
# Run the updater script
/bin/bash .github/workflows/updater.sh
- name: Commit changes
id: commit
if: ${{ env.PROCEED == 'true' }}
run: |
git commit -am "Upgrade to v$VERSION"
- name: Create Pull Request
id: cpr
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update to version ${{ env.VERSION }}
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
signoff: false
base: testing
branch: ci-auto-update-v${{ env.VERSION }}
delete-branch: true
title: 'Upgrade to version ${{ env.VERSION }}'
body: |
Upgrade to v${{ env.VERSION }}
draft: false

View file

@ -18,31 +18,13 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Run VS Code on your server and access it in the browser Run VS Code on your server and access it in the browser
**Shipped version:** 4.13.0~ynh1
**Shipped version:** 4.13.0~ynh2
## Screenshots ## Screenshots
![Screenshot of code-server](./doc/screenshots/screenshot.png) ![Screenshot of code-server](./doc/screenshots/screenshot.png)
## Disclaimers / important information
### Installation
* The package does not create a dedicated system user, rather during installation you are asked what user you want code-server to run as. **Don't give access to users you don't fully trust!**
### Limitations
* Requires a dedicated domain
* `code-server` run as the user you choose during the install
* `code-server` files are stored inside `/home/<your-user>/.local/share/code-server`
* Subdomains for services on ports (like 8080.code-server-domain.tld) are not supported
### Extensions
This application uses [Open VSX Registry](https://open-vsx.org/). You can change this setting from the config panel.
See https://coder.com/docs/code-server/latest/FAQ#how-do-i-use-my-own-extensions-marketplace
## Documentation and resources ## Documentation and resources
* Official app website: <https://coder.com> * Official app website: <https://coder.com>

View file

@ -16,33 +16,15 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
## Vue densemble ## Vue densemble
Lancez VS Code sur votre serveur et accédez-y depuis votre navigateur Run VS Code on your server and access it in the browser
**Version incluse :** 4.13.0~ynh1
**Version incluse :** 4.13.0~ynh2
## Captures décran ## Captures décran
![Capture décran de code-server](./doc/screenshots/screenshot.png) ![Capture décran de code-server](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
### Installation
* Le paquet ne crée pas d'utilisateur système dédié; on vous demandera pendant l'installation quel utilisateur vous voulez que code-serveur éxecute en tant que. **Ne donnez pas accès à des utilisateurs en lesquels vous n'avez pas complètement confiance !**
### Limitations
* Nécessite un domaine dédié
* `code-server` s'éxécute avec l'utilisateur choisir lors de l'installation
* Les fichiers de `code-server` sont stockés dans `/home/<votre-utilisateur>/.local/share/code-server`
* Les sous-domaines pour les services sur les ports (like 8080.code-server-domain.tld) ne sont pas pris en charge
### Extensions
Cette application utilie le [catalogue Open VSX](https://open-vsx.org/). Vous pouvez changer ce paramètre depuis le panneau de configuration.
Voir https://coder.com/docs/code-server/latest/FAQ#how-do-i-use-my-own-extensions-marketplace *(en anglais)*
## Documentations et ressources ## Documentations et ressources
* Site officiel de lapp : <https://coder.com> * Site officiel de lapp : <https://coder.com>

View file

@ -1,24 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
admin="john"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=0
setup_public=0
upgrade=1
upgrade=1 from_commit=d4d938378a7b807264f82797cb297daebd1600f0
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=d4d938378a7b807264f82797cb297daebd1600f0
name=4.2.0~ynh1
manifest_arg=domain=domain.tld&admin=john&is_public=1&password=pass&extension_service_url=&extension_item_url=&enable_proposed_api=

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/coder/code-server/releases/download/v4.13.0/code-server-4.13.0-linux-amd64.tar.gz
SOURCE_SUM=de103fb2d7f6df1395c6a6692c1dccb1474895cd2bc467be457e039ab9d858ac
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/coder/code-server/releases/download/v4.13.0/code-server-4.13.0-linux-arm64.tar.gz
SOURCE_SUM=e9d81ae13a6f02c3350c0eca021d6b0b381bf459475fcbcc3e861fa3d19b1eff
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/coder/code-server/releases/download/v4.13.0/code-server-4.13.0-linux-armv7l.tar.gz
SOURCE_SUM=20aed6fb13424edc2c1997e3241dc4c7d51a29e0a3e7349696715f61d10762c7
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -3,5 +3,5 @@ auth: __AUTH__
cert: false cert: false
disable-telemetry: true disable-telemetry: true
disable-update-check: true disable-update-check: true
user-data-dir: __DATADIR__/user-data user-data-dir: __DATA_DIR__/user-data
extensions-dir: __DATADIR__/extensions extensions-dir: __DATA_DIR__/extensions

View file

@ -1,4 +1,6 @@
location / { #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__/; proxy_pass http://127.0.0.1:__PORT__/;
proxy_redirect off; proxy_redirect off;
proxy_set_header Host $host; proxy_set_header Host $host;

View file

@ -6,10 +6,10 @@ After=network.target multi-user.target
Type=simple Type=simple
User=__ADMIN__ User=__ADMIN__
Group=__ADMIN__ Group=__ADMIN__
WorkingDirectory=/home/__ADMIN__/ WorkingDirectory=/home/__ADMIN__
EnvironmentFile=__FINALPATH__/code-server.env EnvironmentFile=__INSTALL_DIR__/code-server.env
ExecStart=__FINALPATH__/bin/code-server --config __FINALPATH__/config.yaml ExecStart=__INSTALL_DIR__/bin/code-server --config __INSTALL_DIR__/config.yaml
StandardOutput=append:/var/log/__APP__/__APP__.log StandardOutput=append:/var/log/__APP__/__ADMIN__.log
StandardError=inherit StandardError=inherit
# Sandboxing options to harden security # Sandboxing options to harden security

View file

@ -13,7 +13,7 @@ services = ["__APP__"]
choices = ["none", "password"] choices = ["none", "password"]
default = "none" default = "none"
optional = false optional = false
bind = ":/opt/yunohost/__APP__/config.yaml" bind = ":__INSTALL_DIR__/config.yaml"
[main.auth.password] [main.auth.password]
ask = "Password" ask = "Password"
@ -36,7 +36,7 @@ services = ["__APP__"]
example = "{\"serviceUrl\": \"https://open-vsx.org/vscode/gallery\",\"itemUrl\": \"https://open-vsx.org/vscode/item\"}" example = "{\"serviceUrl\": \"https://open-vsx.org/vscode/gallery\",\"itemUrl\": \"https://open-vsx.org/vscode/item\"}"
help = "[Documentation](https://coder.com/docs/code-server/latest/FAQ#how-do-i-use-my-own-extensions-marketplace)" help = "[Documentation](https://coder.com/docs/code-server/latest/FAQ#how-do-i-use-my-own-extensions-marketplace)"
optional = false optional = false
bind = ":/opt/yunohost/__APP__/code-server.env" bind = ":__INSTALL_DIR__/code-server.env"
[main.extensions.enable_proposed_api] [main.extensions.enable_proposed_api]
ask = "Enable Proposed API" ask = "Enable Proposed API"

13
doc/ADMIN.md Normal file
View file

@ -0,0 +1,13 @@
### Installation
* VS Code will run as the user you choose during the installation.
### Limitations
* `code-server` files are stored inside `/home/yunohost.app/<your-user>/.local/share/code-server`
### Extensions
This application uses [Open VSX Registry](https://open-vsx.org/). You can change this setting from the config panel.
See https://coder.com/docs/code-server/latest/FAQ#how-do-i-use-my-own-extensions-marketplace

13
doc/ADMIN_fr.md Normal file
View file

@ -0,0 +1,13 @@
### Installation
* VS Code sera éxecuté en tant que l'utilisateurice sélectionnée lors de l'installation.
### Limitations
* Les fichiers de `code-server` sont stockés dans `/home/yunohost.app/<votre-utilisateur>/.local/share/code-server`
### Extensions
Cette application utilie le [catalogue Open VSX](https://open-vsx.org/). Vous pouvez changer ce paramètre depuis le panneau de configuration.
Voir https://coder.com/docs/code-server/latest/FAQ#how-do-i-use-my-own-extensions-marketplace *(en anglais)*

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Run VS Code on your server and access it in the browser

View file

@ -1,16 +0,0 @@
### Installation
* The package does not create a dedicated system user, rather during installation you are asked what user you want code-server to run as. **Don't give access to users you don't fully trust!**
### Limitations
* Requires a dedicated domain
* `code-server` run as the user you choose during the install
* `code-server` files are stored inside `/home/<your-user>/.local/share/code-server`
* Subdomains for services on ports (like 8080.code-server-domain.tld) are not supported
### Extensions
This application uses [Open VSX Registry](https://open-vsx.org/). You can change this setting from the config panel.
See https://coder.com/docs/code-server/latest/FAQ#how-do-i-use-my-own-extensions-marketplace

View file

@ -1,16 +0,0 @@
### Installation
* Le paquet ne crée pas d'utilisateur système dédié; on vous demandera pendant l'installation quel utilisateur vous voulez que code-serveur éxecute en tant que. **Ne donnez pas accès à des utilisateurs en lesquels vous n'avez pas complètement confiance !**
### Limitations
* Nécessite un domaine dédié
* `code-server` s'éxécute avec l'utilisateur choisir lors de l'installation
* Les fichiers de `code-server` sont stockés dans `/home/<votre-utilisateur>/.local/share/code-server`
* Les sous-domaines pour les services sur les ports (like 8080.code-server-domain.tld) ne sont pas pris en charge
### Extensions
Cette application utilie le [catalogue Open VSX](https://open-vsx.org/). Vous pouvez changer ce paramètre depuis le panneau de configuration.
Voir https://coder.com/docs/code-server/latest/FAQ#how-do-i-use-my-own-extensions-marketplace *(en anglais)*

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 KiB

After

Width:  |  Height:  |  Size: 312 KiB

View file

@ -1,48 +0,0 @@
{
"name": "code-server",
"id": "code-server",
"packaging_format": 1,
"description": {
"en": "Run VS Code on your server and access it in the browser",
"fr": "Lancez VS Code sur votre serveur et accédez-y depuis votre navigateur"
},
"version": "4.13.0~ynh1",
"url": "https://github.com/coder/code-server",
"upstream": {
"license": "MIT",
"website": "https://coder.com",
"admindoc": "https://coder.com/docs/code-server/latest",
"userdoc": "https://coder.com/docs/code-server/latest/FAQ",
"code": "https://github.com/coder/code-server",
"cpe": "cpe:2.3:a:coder:code-server"
},
"antifeatures": {
"non-free-addons": {
"en": "Extensions from the Store might be closed source.",
"fr": "Les extensions disponibles sur la gallerie peuvent être privatrices."
}
},
"license": "MIT",
"maintainer": {
"name": "Tagada"
},
"requirements": {
"yunohost": ">= 4.3.1.8"
},
"multi_instance": true,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "admin",
"type": "user"
}
]
}
}

62
manifest.toml Normal file
View file

@ -0,0 +1,62 @@
packaging_format = 2
id = "code-server"
name = "code-server"
description.en = "Run VS Code on your server and access it in the browser"
description.fr = "Lancez VS Code sur votre serveur et accédez-y depuis votre navigateur"
version = "4.13.0~ynh2"
maintainers = ["Tagada"]
[upstream]
license = "MIT"
website = "https://coder.com"
admindoc = "https://coder.com/docs/code-server/latest"
userdoc = "https://coder.com/docs/code-server/latest/FAQ"
code = "https://github.com/coder/code-server"
[integration]
yunohost = ">= 11.1.17"
architectures = ["amd64", "arm64", "armhf"]
multi_instance = true
ldap = false
sso = false
disk = "500M"
ram.build = "50M"
ram.runtime = "100M"
[install]
[install.domain]
type = "domain"
full_domain = true
[install.admin]
type = "user"
[resources]
[resources.sources.main]
amd64.url = "https://github.com/coder/code-server/releases/download/v4.13.0/code-server-4.13.0-linux-amd64.tar.gz"
amd64.sha256 = "de103fb2d7f6df1395c6a6692c1dccb1474895cd2bc467be457e039ab9d858ac"
arm64.url = "https://github.com/coder/code-server/releases/download/v4.13.0/code-server-4.13.0-linux-arm64.tar.gz"
arm64.sha256 = "e9d81ae13a6f02c3350c0eca021d6b0b381bf459475fcbcc3e861fa3d19b1eff"
armhf.url = "https://github.com/coder/code-server/releases/download/v4.13.0/code-server-4.13.0-linux-armv7l.tar.gz"
armhf.sha256 = "20aed6fb13424edc2c1997e3241dc4c7d51a29e0a3e7349696715f61d10762c7"
autoupdate.strategy = "latest_github_release"
autoupdate.asset.arm64 = "code-server-*-linux-arm64.tar.gz"
autoupdate.asset.amd64 = "code-server-*-linux-amd64.tar.gz"
autoupdate.asset.armhf = "code-server-*-linux-armv7l.tar.gz"
[resources.ports]
[resources.system_user]
[resources.install_dir]
dir = "/opt/yunohost/__APP__"
[resources.data_dir]
subdirs = ["user-data", "extensions"]
[resources.permissions]
main.url = "/"

View file

@ -10,28 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/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..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -41,13 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
ynh_backup --src_path="$datadir" --is_big ynh_backup --src_path="$data_dir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -9,53 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/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='/'
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -70,23 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
# 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
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
@ -97,13 +34,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,75 +9,24 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN
admin=$YNH_APP_ARG_ADMIN
auth="none" auth="none"
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url="/"
# Check machine architecture (in particular, we don't support 32bit machines)
if [ $YNH_ARCH == "i386" ] || [ $YNH_ARCH == "armel" ]
then
ynh_die --message="Sorry, but this app can only be installed on a x86 or ARM, 64 bits machine :("
fi
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=auth --value=$auth ynh_app_setting_set --app=$app --key=auth --value=$auth
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=5 ynh_script_progression --message="Setting up source files..." --weight=5
ynh_app_setting_set --app=$app --key=final_path --value=$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 --dest_dir="$final_path" --source_id="$YNH_ARCH" ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R root:$admin "$install_dir"
chown -R root:$admin "$final_path" chmod +x "$install_dir/bin/code-server"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -87,64 +36,33 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=5
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= # Create a dedicated systemd config
# SPECIFIC SETUP ynh_add_systemd_config
#=================================================
# ...
#=================================================
#================================================= # Use logrotate to manage application logfile(s)
# CREATE DATA DIRECTORY ynh_use_logrotate
#=================================================
ynh_script_progression --message="Creating a data directory..." --weight=2
datadir=/home/$app/.local/share/code-server yunohost service add $app --description="VS Code Server" --log="/var/log/$app/$app.log"
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
mkdir -p $datadir/{user-data,extensions}
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $admin:$admin "$datadir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2 ynh_script_progression --message="Adding a configuration file..." --weight=2
ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
chmod 440 "$install_dir/config.yaml"
chown root:$admin "$install_dir/config.yaml"
chmod 440 "$final_path/config.yaml" ynh_add_config --template="code-server.env" --destination="$install_dir/code-server.env"
chown root:$admin "$final_path/config.yaml" chmod 440 "$install_dir/code-server.env"
chown root:$admin "$install_dir/code-server.env"
ynh_add_config --template="code-server.env" --destination="$final_path/code-server.env"
chmod 440 "$final_path/code-server.env"
chown root:$admin "$final_path/code-server.env"
#================================================= #=================================================
# SETUP SYSTEMD # SET PERMISSION FOR THE USER
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2 ynh_permission_update --permission="main" --add="$admin"
# Create a dedicated systemd config chown -R $admin:$admin "$data_dir"
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=2
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="VS Code Server" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -154,21 +72,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
ynh_permission_update --permission="main" --remove="all_users"
ynh_permission_update --permission="main" --add=$admin
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,18 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
@ -34,65 +22,18 @@ then
yunohost service remove $app yunohost service remove $app
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=2
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE DATA DIR
#=================================================
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$datadir"
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=1
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# ...
#=================================================
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,70 +10,24 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/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_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
ynh_user_exists --username=$admin || ynh_die --message="User $admin doesn't exist "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R root:$admin "$install_dir"
chown -R root:$admin "$final_path"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$datadir" --not_mandatory ynh_restore_file --origin_path="$data_dir" --not_mandatory
mkdir -p $datadir/{user-data,extensions} chown -R $admin:$admin "$data_dir"
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $admin:$admin "$datadir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -82,25 +36,23 @@ chown -R $admin:$admin "$datadir"
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="VS Code Server" --log="/var/log/$app/$app.log" yunohost service add $app --description="VS Code Server" --log="/var/log/$app/$app.log"
#=================================================
# SET PERMISSION FOR THE USER
#=================================================
ynh_permission_update --permission="main" --add="$admin"
chown -R $admin:$admin "$data_dir"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
@ -108,13 +60,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================

View file

@ -9,43 +9,12 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
admin=$(ynh_app_setting_get --app=$app --key=admin)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
auth=$(ynh_app_setting_get --app=$app --key=auth)
hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password)
enable_proposed_api=$(ynh_app_setting_get --app=$app --key="enable_proposed_api")
extensions_gallery=$(ynh_app_setting_get --app=$app --key="extensions_gallery")
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -93,20 +62,8 @@ then
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
ynh_secure_remove --file=$final_path ynh_secure_remove --file=$install_dir
mkdir -p $final_path mkdir -p $install_dir
fi
if ynh_compare_current_package_version -c le -v "4.1.0~ynh1"
then
new_datadir=/home/$app/.local/share/code-server
mkdir -p $new_datadir
cp -R $datadir/* $new_datadir
ynh_secure_remove --file=$datadir
datadir=new_datadir
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
fi fi
#================================================= #=================================================
@ -118,12 +75,12 @@ then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# 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 --dest_dir="$final_path" --source_id="$YNH_ARCH" ynh_setup_source --dest_dir="$install_dir"
fi fi
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R root:$admin "$install_dir"
chown -R root:$admin "$final_path" chmod +x "$install_dir/bin/code-server"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -133,27 +90,21 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
#=================================================
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml"
ynh_add_config --template="code-server.env" --destination="$final_path/code-server.env" ynh_add_config --template="code-server.env" --destination="$install_dir/code-server.env"
if [ "$auth" == "password" ] if [ "$auth" == "password" ]
then then
echo "hashed-password: $hashed_password" >> "$final_path/config.yaml" echo "hashed-password: $hashed_password" >> "$install_dir/config.yaml"
fi fi
chmod 440 "$final_path/config.yaml" "$final_path/code-server.env" chmod 440 "$install_dir/config.yaml" "$install_dir/code-server.env"
chown root:$admin "$final_path/config.yaml" "$final_path/code-server.env" chown $admin:$admin "$install_dir/config.yaml" "$install_dir/code-server.env"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -180,6 +131,13 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="VS Code Server" --log="/var/log/$app/$app.log" yunohost service add $app --description="VS Code Server" --log="/var/log/$app/$app.log"
#=================================================
# SET PERMISSION FOR THE USER
#=================================================
ynh_permission_update --permission="main" --add="$admin"
chown -R $admin:$admin "$data_dir"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
@ -187,13 +145,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

9
tests.toml Normal file
View file

@ -0,0 +1,9 @@
test_format = 1.0
[default]
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.ce90098.name = "Upgrade from 4.13.0"