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

restic rest-server 0.12.1 initial package #5550

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions cross/restic-rest-server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PKG_NAME = restic-rest-server
PKG_REAL_NAME = rest-server
PKG_VERS = 0.12.1
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_REAL_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/restic/rest-server/releases/download/v$(PKG_VERS)
EXTRACT_PATH = $(WORK_DIR)/$(PKG_NAME)
PKG_DIR = $(PKG_NAME)

BUILD_DEPENDS = native/go

HOMEPAGE = https://restic.net/
COMMENT = Rest Server is a high performance HTTP server that implements restic's REST backend API.
LICENSE = BSD 2-Clause License

GO_SRC_DIR = $(EXTRACT_PATH)
GO_BIN_DIR = $(GO_SRC_DIR)/$(PKG_NAME)

ENV += CGO_ENABLED=0

GO_BUILD_ARGS = ./cmd/rest-server

include ../../mk/spksrc.cross-go.mk
1 change: 1 addition & 0 deletions cross/restic-rest-server/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin:bin/restic-rest-server
3 changes: 3 additions & 0 deletions cross/restic-rest-server/digests
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rest-server-0.12.1.tar.gz SHA1 50a68154ffebc228bffae7cd06744a9224fdb9b9
rest-server-0.12.1.tar.gz SHA256 f1b4e4ce581d698847c8a4a354a7fe201b073ebca223abf01898c53d87ccbf31
rest-server-0.12.1.tar.gz MD5 970aa609b3a2793b82480cc4344881ef
2 changes: 1 addition & 1 deletion mk/spksrc.cross-go-env.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ifeq ($(GO_ARCH),)
endif

# Use -buildvcs=false to disable VCS stamping.
GO_BUILD_ARGS += -buildvcs=false
GO_BUILD_ARGS := -buildvcs=false $(GO_BUILD_ARGS)

ifeq ($(strip $(GO_STATIC_BINARIES)),1)
GO_BUILD_ARGS += -no-upgrade
Expand Down
29 changes: 29 additions & 0 deletions spk/restic-rest-server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SPK_NAME = restic-rest-server
SPK_VERS = 0.12.1
SPK_REV = 1
SPK_ICON = src/logo.png

DEPENDS = cross/restic-rest-server

UNSUPPORTED_ARCHS = $(PPC_ARCHS)

MAINTAINER = fgma
DESCRIPTION = Rest Server is a high performance HTTP server that implements restic's REST backend API.
DISPLAY_NAME = Restic rest-server
CHANGELOG = "Initial release."
LICENSE_FILE = $(WORK_DIR)/restic-rest-server/LICENSE
HOMEPAGE = https://restic.net/
LICENSE = BSD 2-Clause License

WIZARDS_DIR = src/wizard

STARTABLE = yes
SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh
SERVICE_WIZARD_SHARE = wizard_data_directory
USE_DATA_SHARE_WORKER = yes
Comment on lines +23 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the new version for shared folders:

define SERVICE_WIZARD_SHARE_NAME
and remove SERVICE_WIZARD_SHARE and USE_DATA_SHARE_WORKER
and remove the volume configuration in the install and uninstall wizards (use the share name only in the install and uninstall wizard)

FWPORTS = src/restic-rest-server.sc
SERVICE_PORT = 8500
NO_SERVICE_SHORTCUT = yes

include ../../mk/spksrc.spk.mk
Binary file added spk/restic-rest-server/src/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions spk/restic-rest-server/src/restic-rest-server.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[restic-rest-server]
title="Restic rest-server"
desc="Restic rest-server"
port_forward="yes"
dst.ports="8500/tcp"
52 changes: 52 additions & 0 deletions spk/restic-rest-server/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

PATH="${SYNOPKG_PKGDEST}/bin:${PATH}"
GROUP="sc-restic-rest-server"

# Source installer variables and functions to be available for service start (and not only during installation)
INST_FUNCTIONS=$(dirname $0)"/functions"
if [ -r "${INST_FUNCTIONS}" ]; then
. "${INST_FUNCTIONS}"
fi

load_variables_from_file "${INST_VARIABLES}"

REST_SERVER_CUSTOM_ARGS_FILE="${WIZARD_DATA_VOLUME}/${WIZARD_DATA_DIRECTORY}/restic_rest_server_custom_args.txt"

service_prestart ()
{
ARGS=""

if [ "${WIZARD_APPEND_ONLY}" == "true" ]; then
ARGS="${ARGS} --append-only"
fi
if [ "${WIZARD_PRIVATE_REPOS}" == "true" ]; then
ARGS="${ARGS} --private-repos"
fi
if [ "${WIZARD_PROMETHEUS}" == "true" ]; then
ARGS="${ARGS} --prometheus"

if [ "${WIZARD_PROMETHEUS_NO_AUTH}" == "true" ]; then
ARGS="${ARGS} --prometheus-no-auth"
fi
fi
if [ -f "$REST_SERVER_CUSTOM_ARGS_FILE" -a -r "$REST_SERVER_CUSTOM_ARGS_FILE" ]; then
CUSTOM_ARGS=`cat ${REST_SERVER_CUSTOM_ARGS_FILE}`
ARGS="${ARGS} ${CUSTOM_ARGS}"
fi

SERVICE_COMMAND="${SYNOPKG_PKGDEST}/bin/restic-rest-server --listen ":${SERVICE_PORT}" --path ${WIZARD_DATA_VOLUME}/${WIZARD_DATA_DIRECTORY} ${ARGS}"
SVC_BACKGROUND=y
SVC_WRITE_PID=y
}

service_postinst ()
{
touch ${wizard_data_volume}/${wizard_data_directory}/.htpasswd
touch ${REST_SERVER_CUSTOM_ARGS_FILE}
echo WIZARD_DATA_VOLUME="${wizard_data_volume}" >> ${INST_VARIABLES}
echo WIZARD_DATA_DIRECTORY="${wizard_data_directory}" >> ${INST_VARIABLES}
echo WIZARD_APPEND_ONLY="${wizard_append_only}" >> ${INST_VARIABLES}
echo WIZARD_PRIVATE_REPOS="${wizard_private_repos}" >> ${INST_VARIABLES}
echo WIZARD_PROMETHEUS="${wizard_prometheus}" >> ${INST_VARIABLES}
echo WIZARD_PROMETHEUS_NO_AUTH="${wizard_prometheus_no_auth}" >> ${INST_VARIABLES}
}
108 changes: 108 additions & 0 deletions spk/restic-rest-server/src/wizard/install_uifile
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
[
{
"step_title": "Restic rest-server configuration",
"items": [
{
"type": "combobox",
"desc": "Please select a volume to use for the data folder",
"subitems": [
{
"key": "wizard_data_volume",
"desc": "Volume name",
"displayField": "display_name",
"valueField": "volume_path",
"editable": false,
"mode": "remote",
"api_store": {
"api": "SYNO.Core.Storage.Volume",
"method": "list",
"version": 1,
"baseParams": {
"limit": -1,
"offset": 0,
"location": "internal"
},
"root": "volumes",
"idProperty": "volume_path",
"fields": [
"display_name",
"volume_path"
]
},
"validator": {
"fn": "{console.log(arguments);return true;}"
}
}
]
},
{
"type": "textfield",
"desc": "Data shared folder (using the volume chosen above)",
"subitems": [
{
"key": "wizard_data_directory",
"desc": "Data shared folder",
"defaultValue": "restic-rest-server",
"validator": {
"allowBlank": false,
"regex": {
"expr": "/^[\\w _-]+$/",
"errorText": "Subdirectories are not supported."
}
}
}
]
},
{
"desc": "The folder will be created on demand as regular DSM shared folder for the service user <b>sc-restic-rest-server</b>. For details about the DSM permissions see <a target=\"_blank\" href=\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\">Permission Management</a>.<p/>"
},
{
"desc": "The non-standard port 8500 is used. The .htpasswd file and restic_rest_server_custom_args.txt to specify custom arguments to the service are located at the root of the shared folder defined above. Add users acccording to the official documentation. Please define the following additional settings for restic rest-server:"
},
{
"type": "multiselect",
"desc": "Append only mode",
"subitems": [
{
"key": "wizard_append_only",
"desc": "enabled",
"defaultValue": true
}
]
},
{
"type": "multiselect",
"desc": "Private repositories",
"subitems": [
{
"key": "wizard_private_repos",
"desc": "enabled",
"defaultValue": true
}
]
},
{
"type": "multiselect",
"desc": "Prometheus",
"subitems": [
{
"key": "wizard_prometheus",
"desc": "enabled",
"defaultValue": true
}
]
},
{
"type": "multiselect",
"desc": "Prometheus no auth",
"subitems": [
{
"key": "wizard_prometheus_no_auth",
"desc": "enabled",
"defaultValue": false
}
]
}
]
}
]
127 changes: 127 additions & 0 deletions spk/restic-rest-server/src/wizard/upgrade_uifile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/bin/sh

INST_ETC="/var/packages/${SYNOPKG_PKGNAME}/etc"
INST_VARIABLES="${INST_ETC}/installer-variables"

# Reload wizard variables stored by postinst
if [ -r "${INST_VARIABLES}" ]; then
# we cannot source the file to reload the variables, when values have special characters like <, >, ...
for _line in $(cat "${INST_VARIABLES}"); do
_key="$(echo ${_line} | awk -F'=' '{print $1}')"
_value="$(echo ${_line} | awk -F'=' '{print $2}')"
declare "${_key}=${_value}"
done
fi

cat <<EOF > $SYNOPKG_TEMP_LOGFILE
[
{
"step_title": "Restic rest-server configuration",
"items": [
{
"type": "combobox",
"desc": "Please select a volume to use for the data folder",
"subitems": [
{
"key": "wizard_data_volume",
"desc": "Volume name",
"defaultValue": "${WIZARD_DATA_VOLUME}",
"displayField": "display_name",
"valueField": "volume_path",
"editable": false,
"mode": "remote",
"api_store": {
"api": "SYNO.Core.Storage.Volume",
"method": "list",
"version": 1,
"baseParams": {
"limit": -1,
"offset": 0,
"location": "internal"
},
"root": "volumes",
"idProperty": "volume_path",
"fields": [
"display_name",
"volume_path"
]
},
"validator": {
"fn": "{console.log(arguments);return true;}"
}
}
]
},
{
"type": "textfield",
"desc": "Data shared folder (using the volume chosen above)",
"subitems": [
{
"key": "wizard_data_directory",
"desc": "Data shared folder",
"defaultValue": "${WIZARD_DATA_DIRECTORY}",
"validator": {
"allowBlank": false,
"regex": {
"expr": "/^[\\\\w _-]+$/",
"errorText": "Subdirectories are not supported."
}
}
}
]
},
{
"desc": "The folder will be created on demand as regular DSM shared folder for the service user <b>sc-restic-rest-server</b>. For details about the DSM permissions see <a target=\"_blank\" href=\"https://github.com/SynoCommunity/spksrc/wiki/Permission-Management\">Permission Management</a>.<p/>"
},
{
"desc": "The non-standard port 8500 is used. The .htpasswd file and restic_rest_server_custom_args.txt to specify custom arguments to the service are located at the root of the shared folder defined above. Add users acccording to the official documentation. Please define the following additional settings for restic rest-server:"
},
{
"type": "multiselect",
"desc": "Append only mode",
"subitems": [
{
"key": "wizard_append_only",
"desc": "enabled",
"defaultValue": ${WIZARD_APPEND_ONLY}
}
]
},
{
"type": "multiselect",
"desc": "Private repositories",
"subitems": [
{
"key": "wizard_private_repos",
"desc": "enabled",
"defaultValue": ${WIZARD_PRIVATE_REPOS}
}
]
},
{
"type": "multiselect",
"desc": "Prometheus",
"subitems": [
{
"key": "wizard_prometheus",
"desc": "enabled",
"defaultValue": ${WIZARD_PROMETHEUS}
}
]
},
{
"type": "multiselect",
"desc": "Prometheus no auth",
"subitems": [
{
"key": "wizard_prometheus_no_auth",
"desc": "enabled",
"defaultValue": ${WIZARD_PROMETHEUS_NO_AUTH}
}
]
}
]
}
]
EOF
exit 0