diff --git a/spk/demoservice/Makefile b/spk/demoservice/Makefile index 7a5f0efa8a6..d084e905601 100644 --- a/spk/demoservice/Makefile +++ b/spk/demoservice/Makefile @@ -1,29 +1,26 @@ SPK_NAME = demoservice SPK_VERS = 1.2 -SPK_REV = 8 +SPK_REV = 9 SPK_ICON = src/demoservice.png +# force noarch target override ARCH= MAINTAINER = ymartin59 -DESCRIPTION = Demonstration package to show installer script capabilities when requiring non-root user for background service +DESCRIPTION = Demonstration package to show installer script capabilities when requiring non-root user for background service.
Further more this package creates a demo MySQL database. Upon deinstallation the demo database and/or user can be kept or droped. DISPLAY_NAME = DemoService -CHANGELOG = "1. Update with new installer logs
2. Update for DSM7" +CHANGELOG = "1. Update with new installer logs
2. Update for DSM7.
3. Add db creation demo." LICENSE = GPLv2 WIZARDS_DIR = src/wizard/ +# The demo database is created by definitions in conf/resource and controlled by wizard variables. +CONF_DIR = src/conf/ # 'auto' reserved value grabs SPK_NAME SERVICE_USER = auto SERVICE_WIZARD_GROUP = wizard_group - -include ../../mk/spksrc.common.mk -ifneq ($(call version_ge, ${TCVERSION}, 7.0),1) -# SERVICE_WIZARD_SHARE is not supported for DSM7 yet SERVICE_WIZARD_SHARE = wizard_download_dir -endif - SERVICE_SETUP = src/service-setup.sh STARTABLE = yes @@ -41,7 +38,8 @@ include ../../mk/spksrc.spk.mk .PHONY: demoservice_install # Replace standard copy/install targets, no sources, no content demoservice_pre_copy: - rm -fr $(STAGING_DIR) + rm -rf $(STAGING_DIR) mkdir $(STAGING_DIR) mkdir --parents $(STAGING_INSTALL_PREFIX)/var - echo "Test file for $(INSTALL_PREFIX)/var" > $(STAGING_INSTALL_PREFIX)/var/README + echo "No files package with MySQL DB creation." > $(STAGING_INSTALL_PREFIX)/var/README + diff --git a/spk/demoservice/src/conf/resource b/spk/demoservice/src/conf/resource new file mode 100644 index 00000000000..17e10b09255 --- /dev/null +++ b/spk/demoservice/src/conf/resource @@ -0,0 +1,17 @@ +{ + "mysql-db": { + "info": { + "db-name": "demoservice" + }, + "root-pw": "{{wizard_mysql_password_root}}", + "create-db" : { + "db-collision": "skip" + }, + "grant-user": { + "user-name" : "demoservice", + "rand-pw" : true + }, + "drop-db-uninst": "{{wizard_mysql_drop_database}}", + "drop-user-uninst": "{{wizard_mysql_drop_db_user}}" + } +} diff --git a/spk/demoservice/src/service-setup.sh b/spk/demoservice/src/service-setup.sh index 65656689824..f3b535c2245 100644 --- a/spk/demoservice/src/service-setup.sh +++ b/spk/demoservice/src/service-setup.sh @@ -15,7 +15,7 @@ SERVICE_COMMAND="python -m ${SERVER_MODULE} ${SERVICE_PORT}" SVC_CWD="${SYNOPKG_PKGVAR}" SVC_BACKGROUND=y SVC_WRITE_PID=y - +DEMOSERVICE_INI=${SYNOPKG_PKGDEST}/var/demoservice.ini # These functions are for demonstration purpose of DSM sequence call # and installation logging capabilities. @@ -69,13 +69,16 @@ service_preinst () service_postinst () { echo "service_postinst ${SYNOPKG_PKG_STATUS}" - - ln -sf ${INST_LOG} ${SYNOPKG_PKGVAR}/installer.log + echo "# Database created with random password:" > ${DEMOSERVICE_INI} + echo "${SYNOPKG_DB_USER_RAND_PW}" >> ${DEMOSERVICE_INI} + echo "ini file created: ${DEMOSERVICE_INI}" } service_preuninst () { echo "service_preuninst ${SYNOPKG_PKG_STATUS}" + echo "wizard_mysql_drop_database = ${wizard_mysql_drop_database}" >> $INST_LOG + echo "wizard_mysql_drop_db_user = ${wizard_mysql_drop_db_user}" >> $INST_LOG } service_postuninst () diff --git a/spk/demoservice/src/wizard/install_uifile b/spk/demoservice/src/wizard/install_uifile index 83cc56f0f13..8744e02b048 100644 --- a/spk/demoservice/src/wizard/install_uifile +++ b/spk/demoservice/src/wizard/install_uifile @@ -35,11 +35,24 @@ ] }, { - "step_title": "Attention! DSM Permissions", + "step_title": "DSM Permissions", "items": [ { "desc": "Permissions are managed with the group 'sc-download' in DSM.
The group 'users' is no longer used as of DSM 6.
Package user (= demoservice) will not appear on most UI settings.
Including the following:
- Application privilege's permission viewer
- FPT's chroot user selector
- File Stations's
- Change owner
- Shared Links Manager -> Enable secure sharing

The only exceptions are:
- Control Panel > Shared Folder > Edit > Permission > System internal user
- ACL editor
" } ] + }, + { + "step_title": "Create MySQL Demo Database", + "items": [{ + "desc": "This package creates a demo database 'demoservice' and a db user 'demoservice' with full access to this database. The password for the db user is randomly generated by DSM and is stored in the file demoservice.ini by package specific install function.
" + },{ + "type": "password", + "desc": "Enter your MySQL root password", + "subitems": [{ + "key": "wizard_mysql_password_root", + "desc": "MySQL root password" + }] + }] } -] \ No newline at end of file +] diff --git a/spk/demoservice/src/wizard/install_uifile_fre b/spk/demoservice/src/wizard/install_uifile_fre index 91c482281fb..3a6d55c235a 100644 --- a/spk/demoservice/src/wizard/install_uifile_fre +++ b/spk/demoservice/src/wizard/install_uifile_fre @@ -35,11 +35,24 @@ ] }, { - "step_title": "Attention! DSM Permissions", + "step_title": "DSM Permissions", "items": [ { "desc": "Les autorisations sont gérées avec le groupe 'sc-download' dans DSM.
Le groupe 'utilisateurs' n'est plus utilisé à partir de DSM 6.
L'utilisateur du paquet (= demoservice) n'apparaîtra pas sur la plupart des paramètres d'interface utilisateur. Y compris ce qui suit:
- Afficheur d'autorisation de privilège d'application
- Sélecteur d'utilisateur chroot FPT
- File Stations's- Changer de propriétaire
- Shared Links Manager -> Activer le partage sécurisé

Les seules exceptions sont:
- Panneau de configuration> Dossier partagé> Edition> Autorisation> Utilisateur interne du système
- Éditeur ACL" } ] + }, + { + "step_title": "Create MySQL Demo Database", + "items": [{ + "desc": "This package creates a demo database 'demoservice' and a db user 'demoservice' with full access to this database. The password for the db user is randomly generated by DSM and is stored in the file demoservice.ini by package specific install function.
" + },{ + "type": "password", + "desc": "Enter your MySQL root password", + "subitems": [{ + "key": "wizard_mysql_password_root", + "desc": "MySQL root password" + }] + }] } ] \ No newline at end of file diff --git a/spk/demoservice/src/wizard/uninstall_uifile b/spk/demoservice/src/wizard/uninstall_uifile new file mode 100644 index 00000000000..4438820f50d --- /dev/null +++ b/spk/demoservice/src/wizard/uninstall_uifile @@ -0,0 +1,25 @@ +[ + { + "step_title": "MySQL Demo Database", + "items": [{ + "type": "password", + "desc": "Enter your MySQL root password if you want to drop the database and/or the db user.", + "subitems": [{ + "key": "wizard_mysql_password_root", + "desc": "MySQL root password" + }] + },{ + "type": "multiselect", + "desc": "Cleanup the Demo Database:", + "subitems": [{ + "key": "wizard_mysql_drop_database", + "desc": "Drop demo database", + "defaultValue": true + },{ + "key": "wizard_mysql_drop_db_user", + "desc": "Drop demo db user", + "defaultValue": true + }] + }] + } +]