swap MODS Sample Simple and Advanced for DSM 7.x

This commit is contained in:
vletroye
2021-02-18 18:15:37 +01:00
parent 6290dd2663
commit d19a0cc978
21 changed files with 255 additions and 250 deletions

View File

@ -2,8 +2,8 @@ arch="noarch"
beta="yes"
ctl_stop="yes"
ctl_uninstall="yes"
description="This is a package created with MODS to illustrate the use of a fake CGI. It's a version of the package 'MODS Sample - Simple CGI 7.x' which requires to a sudoer account 'ModsPackager' in order to be able to deploy it's nginx config."
description_enu="This is a package created with MODS to illustrate the use of a fake CGI. It's a version of the package 'MODS Sample - Simple CGI 7.x' which requires to a sudoer account 'ModsPackager' in order to be able to deploy it's nginx config."
description="This is a package created with MODS to illustrate the use of a fake CGI that runs a simple php website, displayed in a DSM iFrame. It requires dependency neither on the well known package Init_3rdparty not on the Synology WebStation. it reuses the 'Simple php Website' of Banago for illustration purpose. Navigation between pages can be tested as well asAjax calls, Ajax callbacks, Post and Get. This version is targeting DSM 7.x. Due to security restriction during installation, it requires an access onto the NAS via SSH. Credentials of an administrator must be entered (at your own risk) to autorize the execution of commands as sudoer. This is indeed required to configure nginx and run php pages deployed outside the root folder of the WebStation."
description_enu="This is a package created with MODS to illustrate the use of a fake CGI that runs a simple php website, displayed in a DSM iFrame. It requires dependency neither on the well known package Init_3rdparty not on the Synology WebStation. it reuses the 'Simple php Website' of Banago for illustration purpose. Navigation between pages can be tested as well asAjax calls, Ajax callbacks, Post and Get. This version is targeting DSM 7.x. Due to security restriction during installation, it requires an access onto the NAS via SSH. Credentials of an administrator must be entered (at your own risk) to autorize the execution of commands as sudoer. This is indeed required to configure nginx and run php pages deployed outside the root folder of the WebStation."
displayname="MODS Sample - Advanced CGI 7.x"
displayname_enu="MODS Sample - Advanced CGI 7.x"
distributor="vletroye"
@ -32,5 +32,4 @@ startstop_restart_services="nginx.service"
support_center="no"
support_url="https://github.com/vletroye/SynoPackages/wiki/MODS-Sample-Advanced-Cgi-7.x"
thirdparty="yes"
version="1.0-0126"
checksum="3a087249c749130025b1e18165a5dc45"
version="1.0-0127"

View File

@ -1,32 +1,58 @@
[
{
"step_title": "Installation Guide",
"step_title": "Install parameters",
"invalid_next_disabled": true,
"items": [
{
"type": "textfield",
"desc": "Before installing this package, you must define a sudoer account 'ModsPackager' on your NAS, with rights to run /bin/ln and /bin/unlink without password:",
"subitems": []
"desc": "Enter an administrator account and his password to install this package:",
"subitems": [
{
"blankText": "You must type an account",
"key": "MODS_ADMIN",
"defaultValue": "admin",
"desc": "Account"
}
]
},
{
"type": "password",
"desc": "",
"subitems": [
{
"blankText": "You must type a password",
"key": "MODS_PASSWORD",
"desc": "Password"
}
]
},
{
"type": "multiselect",
"subitems": [
{
"key": "MODS_SAVE",
"defaultValue": "false",
"desc": "Save password"
}
]
},
{
"type": "textfield",
"desc": "1. Connect onto your NAS via SSH (using e.g. the Putty console) as administrator",
"subitems": []
},
{
"type": "textfield",
"desc": "2. Create a sudo file (the name does not matter): sudo vi /etc/sudoers.d/ModsPackager",
"subitems": []
},
{
"type": "textfield",
"desc": "3. Type in this file: ModsPackager ALL=(ALL) NOPASSWD:/bin/ln,/bin/unlink",
"subitems": []
},
{
"type": "textfield",
"desc": "4. Save the file (with :x!)",
"subitems": []
"desc": "Enter the port used to connect via SSH:",
"subitems": [
{
"validator": {
"allowBlank": false,
"regex": {
"errorText": "You must enter a valid port",
"expr": "/^(102[0-3]|10[0-1]\\d|[1-9][0-9]{0,2}|0)$/"
}
},
"key": "MODS_PORT",
"defaultValue": "22",
"desc": "SSH Port"
}
]
}
]
}

View File

@ -1,7 +1,5 @@
{
"defaults": {
"run-as": "package"
},
"username": "ModsPackager",
"groupname": "ModsPackager"
}
}

View File

@ -37,15 +37,6 @@ if [ -z $SYNOPKG_PKGNAME ]; then
fi
LOG="/tmp/$SYNOPKG_PKGNAME.log"
ERR="/tmp/$SYNOPKG_PKGNAME.err"
if [ ! -f $ERR ]; then
touch $ERR
chmod og+w $ERR
fi
if [ ! -f $LOG ]; then
touch $LOG
chmod og+w $LOG
fi
SEP="################################################################################################################################################################################"
WIZARD=0
@ -83,9 +74,63 @@ function ShowLog() {
fi
}
# Execute a command via SSH on the local host, using a php script
function ExecSSH() {
user=$1 # Admin account
pass=$2 # Admin password
port=$3 # SSH port
cmd=$4 # Command to execute
# Find the php version to be used
version=`php -v | grep "PHP " | cut -f2 -d " "`
major=`echo $version | cut -d. -f1`
minor=`echo $version | cut -d. -f2`
if [ $0 == "-sh" ]; then
# If run from a -sh, assume that the php script os local
path="."
else
path="/var/packages/$SYNOPKG_PKGNAME/scripts"
fi
script="$path/exec.php"
# Call PHP with ssh2 modules
output="$(php -dextension=/var/packages/PHP$major.$minor/target/usr/local/lib/php$major$minor/modules/ssh2.so "$script" -u "$user" -p "$pass" -s "127.0.0.1" -o "$port" -c "$cmd")"
ExitCode=$? #Do not add any line or comment between the command and this line retrieving its exit code!!
LogInfo "$output"
return $ExitCode
}
# Validate credentials to connect via SSH on the local host, using a php script
function CheckSSH() {
user=$1 # Admin account
pass=$2 # Admin password
port=$3 # SSH port
# Find the php version to be used
version=`php -v | grep "PHP " | cut -f2 -d " "`
major=`echo $version | cut -d. -f1`
minor=`echo $version | cut -d. -f2`
if [ $0 == "-sh" ]; then
# If run from a -sh, assume that the php script os local
path="."
else
path="/var/packages/$SYNOPKG_PKGNAME/scripts"
fi
script="$path/check.php"
# Call PHP with ssh2 modules
output="$(php -dextension=/var/packages/PHP$major.$minor/target/usr/local/lib/php$major$minor/modules/ssh2.so "$script" -u "$user" -p "$pass" -s "127.0.0.1" -o "$port")"
ExitCode=$? #Do not add any line of comment between the command and this line retrieving its exit code!!
LogInfo "$output"
return $ExitCode
}
# Link nginx to the package's config file defined to be able to run php scripts outside to web root folder
function LinkNginx() {
LogInfo "I am : `whoami`"
if [ -f $SYNOPKG_PKGDEST/ui/router.cgi ]; then
# Set the name of the package in the router cgi
sed -i -e "s|@SYNOPKG_PKGNAME@|$SYNOPKG_PKGNAME|g" "$SYNOPKG_PKGDEST/ui/router.cgi"
@ -101,29 +146,83 @@ function LinkNginx() {
if [ -f $LINK ]; then
LogInfo "Link to nginx config already exists."
else
sudo /bin/ln -s "$SYNOPKG_PKGDEST/ui/dsm.cgi.conf" "$LINK"
# Check if SSH connection is working
LogInfo "Checking SSH credentials"
CheckSSH "$MODS_ADMIN" "$MODS_PASSWORD" "$MODS_PORT"
ExitCode=$? #Do not add any line of comment between the command and this line retrieving its exit code!!
if [ $ExitCode == 0 ]; then
# Store Admin account and SSH port
if [ ! -z $MODS_ADMIN ]; then
echo "MODS_ADMIN=$MODS_ADMIN" > "/var/packages/$SYNOPKG_PKGNAME/etc/parameters"
echo "MODS_PORT=$MODS_PORT" >> "/var/packages/$SYNOPKG_PKGNAME/etc/parameters"
chmod og-r "/var/packages/$SYNOPKG_PKGNAME/etc/parameters"
fi
# Store Admin password if requested
if [ $MODS_SAVE == "true" ]; then
# Create a Private Key to encrypt the password
if [ ! -f "/var/packages/$SYNOPKG_PKGNAME/etc/image" ]; then
LogInfo "Creating Encryption Key"
openssl genrsa -out /var/packages/$SYNOPKG_PKGNAME/etc/image 2048 2> /dev/null
fi
# Encrypt and store the password
if [ ! -z $MODS_PASSWORD ]; then
LogInfo "Encrypting Password"
echo "$MODS_PASSWORD" | openssl rsautl -inkey /var/packages/$SYNOPKG_PKGNAME/etc/image -encrypt > /var/packages/$SYNOPKG_PKGNAME/etc/backup
chmod og-r /var/packages/$SYNOPKG_PKGNAME/etc/backup
fi
else
LogInfo "Don't store Password"
fi
# Create the Symbolic link
LogInfo "Creating nginx Link"
ExecSSH "$MODS_ADMIN" "$MODS_PASSWORD" "$MODS_PORT" "ln -s $SYNOPKG_PKGDEST/ui/dsm.cgi.conf $LINK"
ExitCode=$?
# Check that the link has been created
if [ ! -f $LINK ]; then
# Check that the link has been created
if [ ! -f $LINK ]; then
PublishInfo ""
PublishInfo "Link Creation failed..."
PublishInfo "Investigate the reason in the Logs"
exit 150
fi
else
PublishInfo ""
PublishInfo "Link Creation failed..."
PublishInfo "Investigate the reason in the Logs"
return 1
fi
PublishInfo "Cannot connect via SSH onto the NAS with provided Login/Password."
PublishInfo "Go back into the Installation Wizard to change your Login/Password."
exit 150
fi
fi
fi
return 0
}
# Unlink nginx config
function UnlinkNginx() {
LogInfo "I am : `whoami`"
if [ $SYNOPKG_PKG_STATUS == "UNINSTALL" ]; then
LINK="/usr/syno/share/nginx/conf.d/dsm.$SYNOPKG_PKGNAME.conf"
if [ -f $LINK ]; then
sudo /bin/unlink "$LINK"
# Retrieve previous credentials if no account received from Wizard
if [ -z $MODS_ADMIN ] && [ -f /var/packages/$SYNOPKG_PKGNAME/etc/backup ]; then
if [ -f /var/packages/$SYNOPKG_PKGNAME/etc/parameters ]; then
. /var/packages/$SYNOPKG_PKGNAME/etc/parameters
fi
if [ -z $MODS_PASSWORD ]; then
LogInfo "Retrieving previous SSH credentials"
MODS_PASSWORD=$(openssl rsautl -inkey /var/packages/$SYNOPKG_PKGNAME/etc/image -decrypt < /var/packages/$SYNOPKG_PKGNAME/etc/backup)
fi
fi
# Unlink nginx configuration
LogInfo "Removing nginx Link"
ExecSSH "$MODS_ADMIN" "$MODS_PASSWORD" "$MODS_PORT" "unlink $LINK"
ExitCode=$?
if [ -f $LINK ]; then
PublishInfo

View File

@ -3,18 +3,13 @@
. `dirname $0`/common `basename $0` $*
StartScript
LinkNginx
ExitCode=$?
if [ $ExitCode == "0" ]; then
EnableRouterLog
if [ $? != 0 ]; then
exit 150
fi
EndScript
LinkNginx
if [ $ExitCode == "0" ]; then
exit 0
else
exit 150
fi
EnableRouterLog
EndScript
exit 0

View File

@ -2,12 +2,12 @@ arch="noarch"
beta="yes"
ctl_stop="yes"
ctl_uninstall="yes"
description="This is a package created with MODS to illustrate the use of a fake CGI that runs a simple php website, displayed in a DSM iFrame. It requires dependency neither on the well known package Init_3rdparty not on the Synology WebStation. it reuses the 'Simple php Website' of Banago for illustration purpose. Navigation between pages can be tested as well asAjax calls, Ajax callbacks, Post and Get. This version is targeting DSM 7.x. Due to security restriction during installation, it requires an access onto the NAS via SSH. Credentials of an administrator must be entered (at your own risk) to autorize the execution of commands as sudoer. This is indeed required to configure nginx and run php pages deployed outside the root folder of the WebStation."
description_enu="This is a package created with MODS to illustrate the use of a fake CGI that runs a simple php website, displayed in a DSM iFrame. It requires dependency neither on the well known package Init_3rdparty not on the Synology WebStation. it reuses the 'Simple php Website' of Banago for illustration purpose. Navigation between pages can be tested as well asAjax calls, Ajax callbacks, Post and Get. This version is targeting DSM 7.x. Due to security restriction during installation, it requires an access onto the NAS via SSH. Credentials of an administrator must be entered (at your own risk) to autorize the execution of commands as sudoer. This is indeed required to configure nginx and run php pages deployed outside the root folder of the WebStation."
description="This is a package created with MODS to illustrate the use of a fake CGI. It's a version of the package 'MODS Sample - Simple CGI 7.x' which requires to a sudoer account 'ModsPackager' in order to be able to deploy it's nginx config."
description_enu="This is a package created with MODS to illustrate the use of a fake CGI. It's a version of the package 'MODS Sample - Simple CGI 7.x' which requires to a sudoer account 'ModsPackager' in order to be able to deploy it's nginx config."
displayname="MODS Sample - Simple CGI 7.x"
displayname_enu="MODS Sample - Simple CGI 7.x"
distributor="vletroye"
distributor_url="https://www.beatificabytes.be/sspks"
distributor_url="https://olympe.letroye.be/sspks"
dsmappname="SYNO.SDS.ThirdParty.App.MODS_Sample_Simple_CGI_7.x"
dsmuidir="ui"
firmware="7.0-40000"
@ -22,7 +22,7 @@ os_min_ver="7.0-40000"
package="MODS_Sample_Simple_CGI_7.x"
precheckstartstop="no"
reloadui="yes"
report_url="https://github.com/vletroye/SynoPackages/wiki"
report_url="https://github.com/vletroye/SynoPackages/issues"
silent_install="no"
silent_uninstall="no"
silent_upgrade="no"
@ -32,5 +32,5 @@ startstop_restart_services="nginx.service"
support_center="no"
support_url="https://github.com/vletroye/SynoPackages/wiki/MODS-Sample-Simple-Cgi-7.x"
thirdparty="yes"
version="1.0-0110"
checksum="0f5f87f61166787c95a86c0bdb63d962"
version="1.0-0111"
checksum="d1dfe3d090fd8c3145a8672ee234f374"

View File

@ -1,58 +1,32 @@
[
{
"step_title": "Install parameters",
"step_title": "Installation Guide",
"invalid_next_disabled": true,
"items": [
{
"type": "textfield",
"desc": "Enter an administrator account and his password to install this package:",
"subitems": [
{
"blankText": "You must type an account",
"key": "MODS_ADMIN",
"defaultValue": "admin",
"desc": "Account"
}
]
},
{
"type": "password",
"desc": "",
"subitems": [
{
"blankText": "You must type a password",
"key": "MODS_PASSWORD",
"desc": "Password"
}
]
},
{
"type": "multiselect",
"subitems": [
{
"key": "MODS_SAVE",
"defaultValue": "false",
"desc": "Save password"
}
]
"desc": "Before installing this package, you must define a sudoer account 'ModsPackager' on your NAS, with rights to run /bin/ln and /bin/unlink without password:",
"subitems": []
},
{
"type": "textfield",
"desc": "Enter the port used to connect via SSH:",
"subitems": [
{
"validator": {
"allowBlank": false,
"regex": {
"errorText": "You must enter a valid port",
"expr": "/^(102[0-3]|10[0-1]\\d|[1-9][0-9]{0,2}|0)$/"
}
},
"key": "MODS_PORT",
"defaultValue": "22",
"desc": "SSH Port"
}
]
"desc": "1. Connect onto your NAS via SSH (using e.g. the Putty console) as administrator",
"subitems": []
},
{
"type": "textfield",
"desc": "2. Create a sudo file (the name does not matter): sudo vi /etc/sudoers.d/ModsPackager",
"subitems": []
},
{
"type": "textfield",
"desc": "3. Type in this file: ModsPackager ALL=(ALL) NOPASSWD:/bin/ln,/bin/unlink",
"subitems": []
},
{
"type": "textfield",
"desc": "4. Save the file (with :x!)",
"subitems": []
}
]
}

View File

@ -1,5 +1,7 @@
{
"defaults": {
"run-as": "package"
}
},
"username": "ModsPackager",
"groupname": "ModsPackager"
}

View File

@ -1,13 +1,13 @@
{
".url": {
"SYNO.SDS.ThirdParty.App.MODS_Sample_Simple_CGI_7.x": {
"SYNO.SDS._ThirdParty.App.MODS_Sample_Simple_CGI_7.x": {
"itemType": 2,
"type": "legacy",
"allUsers": true,
"title": "Mods Simple CGI",
"title": "Mods Advanced CGI",
"desc": "Simple php website running on DSM 7.x without the need for the Init_3rdparty package and WebStation.",
"icon": "images/Mods_Simple_CGI_{0}.png",
"appWindow": "SYNO.SDS.ThirdParty.App.MODS_Sample_Simple_CGI_7.x",
"appWindow": "SYNO.SDS._ThirdParty.App.MODS_Sample_Simple_CGI_7.x",
"url": "/webman/3rdparty/MODS_Sample_Simple_CGI_7.x/index.php",
"allowMultiInstance": false,
"configablePrivilege": true,

View File

@ -26,14 +26,26 @@
# Define temporary Log and Err files
if [ -z $SYNOPKG_PKGNAME ]; then
# Define variables to be able to run from a -sh instead of being run from Synology installer
SYNOPKG_PKGNAME="MODS_DUMMY"
SYNOPKG_PKGDEST="."
LOG="/tmp/$SYNOPKG_PKGNAME.log"
ERR="/tmp/$SYNOPKG_PKGNAME.err"
else
LOG="/tmp/$SYNOPKG_PKGNAME.log"
ERR="/tmp/$SYNOPKG_PKGNAME.err"
SYNOPKG_PKGNAME="$(pwd | cut -d '/' -f4)"
if [ -z $SYNOPKG_PKGNAME ]; then
SYNOPKG_PKGNAME="Dummy"
SYNOPKG_PKGDEST="."
SYNOPKG_TEMP_LOGFILE="/tmp/$SYNOPKG_PKGNAME.log"
else
SYNOPKG_PKGDEST="/var/packages/$SYNOPKG_PKGNAME/target"
fi
fi
LOG="/tmp/$SYNOPKG_PKGNAME.log"
ERR="/tmp/$SYNOPKG_PKGNAME.err"
if [ ! -f $ERR ]; then
touch $ERR
chmod og+w $ERR
fi
if [ ! -f $LOG ]; then
touch $LOG
chmod og+w $LOG
fi
SEP="################################################################################################################################################################################"
WIZARD=0
@ -55,15 +67,15 @@ function ShowLog() {
LogInfo " -f: full display"
LogInfo " -l: keep logs after display"
else
if [ -f /var/log/packages/MODS_Sample_Simple_CGI_7.x.log ]; then
if [ -f /var/log/packages/$SYNOPKG_PKGNAME.log ]; then
if [ $full == 1 ]; then
sudo cat /tmp/MODS* /var/log/packages/MODS_Sample_Simple_CGI_7.x.log
sudo cat /tmp/MODS* /var/log/packages/$SYNOPKG_PKGNAME.log
else
sudo cat /tmp/MODS* /var/log/packages/MODS_Sample_Simple_CGI_7.x.log | grep -v "Begin /bin/" | grep -v "End /bin/"
sudo cat /tmp/MODS* /var/log/packages/$SYNOPKG_PKGNAME.log | grep -v "Begin /bin/" | grep -v "End /bin/"
fi
if [ $keep == 0 ]; then
sudo rm -f /var/log/packages/MODS_Sample_Simple_CGI_7.x.log
sudo rm -f /var/log/packages/$SYNOPKG_PKGNAME.log
fi
#rm -f /tmp/MODS*
@ -71,63 +83,9 @@ function ShowLog() {
fi
}
# Execute a command via SSH on the local host, using a php script
function ExecSSH() {
user=$1 # Admin account
pass=$2 # Admin password
port=$3 # SSH port
cmd=$4 # Command to execute
# Find the php version to be used
version=`php -v | grep "PHP " | cut -f2 -d " "`
major=`echo $version | cut -d. -f1`
minor=`echo $version | cut -d. -f2`
if [ $0 == "-sh" ]; then
# If run from a -sh, assume that the php script os local
path="."
else
path="/var/packages/$SYNOPKG_PKGNAME/scripts"
fi
script="$path/exec.php"
# Call PHP with ssh2 modules
output="$(php -dextension=/var/packages/PHP$major.$minor/target/usr/local/lib/php$major$minor/modules/ssh2.so "$script" -u "$user" -p "$pass" -s "127.0.0.1" -o "$port" -c "$cmd")"
ExitCode=$? #Do not add any line or comment between the command and this line retrieving its exit code!!
LogInfo "$output"
return $ExitCode
}
# Validate credentials to connect via SSH on the local host, using a php script
function CheckSSH() {
user=$1 # Admin account
pass=$2 # Admin password
port=$3 # SSH port
# Find the php version to be used
version=`php -v | grep "PHP " | cut -f2 -d " "`
major=`echo $version | cut -d. -f1`
minor=`echo $version | cut -d. -f2`
if [ $0 == "-sh" ]; then
# If run from a -sh, assume that the php script os local
path="."
else
path="/var/packages/$SYNOPKG_PKGNAME/scripts"
fi
script="$path/check.php"
# Call PHP with ssh2 modules
output="$(php -dextension=/var/packages/PHP$major.$minor/target/usr/local/lib/php$major$minor/modules/ssh2.so "$script" -u "$user" -p "$pass" -s "127.0.0.1" -o "$port")"
ExitCode=$? #Do not add any line of comment between the command and this line retrieving its exit code!!
LogInfo "$output"
return $ExitCode
}
# Link nginx to the package's config file defined to be able to run php scripts outside to web root folder
function LinkNginx() {
LogInfo "I am : `whoami`"
if [ -f $SYNOPKG_PKGDEST/ui/router.cgi ]; then
# Set the name of the package in the router cgi
sed -i -e "s|@SYNOPKG_PKGNAME@|$SYNOPKG_PKGNAME|g" "$SYNOPKG_PKGDEST/ui/router.cgi"
@ -143,85 +101,31 @@ function LinkNginx() {
if [ -f $LINK ]; then
LogInfo "Link to nginx config already exists."
else
# Check if SSH connection is working
LogInfo "Checking SSH credentials"
CheckSSH "$MODS_ADMIN" "$MODS_PASSWORD" "$MODS_PORT"
ExitCode=$? #Do not add any line of comment between the command and this line retrieving its exit code!!
if [ $ExitCode == 0 ]; then
# Store Admin account and SSH port
if [ ! -z $MODS_ADMIN ]; then
echo "MODS_ADMIN=$MODS_ADMIN" > "/var/packages/$SYNOPKG_PKGNAME/etc/parameters"
echo "MODS_PORT=$MODS_PORT" >> "/var/packages/$SYNOPKG_PKGNAME/etc/parameters"
chmod og-r "/var/packages/$SYNOPKG_PKGNAME/etc/parameters"
fi
# Store Admin password if requested
if [ $MODS_SAVE == "true" ]; then
# Create a Private Key to encrypt the password
if [ ! -f "/var/packages/$SYNOPKG_PKGNAME/etc/image" ]; then
LogInfo "Creating Encryption Key"
openssl genrsa -out /var/packages/$SYNOPKG_PKGNAME/etc/image 2048 2> /dev/null
fi
# Encrypt and store the password
if [ ! -z $MODS_PASSWORD ]; then
LogInfo "Encrypting Password"
echo "$MODS_PASSWORD" | openssl rsautl -inkey /var/packages/$SYNOPKG_PKGNAME/etc/image -encrypt > /var/packages/$SYNOPKG_PKGNAME/etc/backup
chmod og-r /var/packages/$SYNOPKG_PKGNAME/etc/backup
fi
else
LogInfo "Don't store Password"
fi
# Create the Symbolic link
LogInfo "Creating nginx Link"
ExecSSH "$MODS_ADMIN" "$MODS_PASSWORD" "$MODS_PORT" "ln -s $SYNOPKG_PKGDEST/ui/dsm.cgi.conf $LINK"
ExitCode=$?
sudo /bin/ln -s "$SYNOPKG_PKGDEST/ui/dsm.cgi.conf" "$LINK"
# Check that the link has been created
if [ ! -f $LINK ]; then
PublishInfo ""
PublishInfo "Link Creation failed..."
PublishInfo "Investigate the reason in the Logs"
exit 150
fi
else
# Check that the link has been created
if [ ! -f $LINK ]; then
PublishInfo ""
PublishInfo "Cannot connect via SSH onto the NAS with provided Login/Password."
PublishInfo "Go back into the Installation Wizard to change your Login/Password."
exit 150
fi
PublishInfo "Link Creation failed..."
PublishInfo "Investigate the reason in the Logs"
return 1
fi
fi
fi
return 0
}
# Unlink nginx config
function UnlinkNginx() {
LogInfo "I am : `whoami`"
if [ $SYNOPKG_PKG_STATUS == "UNINSTALL" ]; then
LINK="/usr/syno/share/nginx/conf.d/dsm.$SYNOPKG_PKGNAME.conf"
if [ -f $LINK ]; then
# Retrieve previous credentials if no account received from Wizard
if [ -z $MODS_ADMIN ] && [ -f /var/packages/$SYNOPKG_PKGNAME/etc/backup ]; then
if [ -f /var/packages/$SYNOPKG_PKGNAME/etc/parameters ]; then
. /var/packages/$SYNOPKG_PKGNAME/etc/parameters
fi
if [ -z $MODS_PASSWORD ]; then
LogInfo "Retrieving previous SSH credentials"
MODS_PASSWORD=$(openssl rsautl -inkey /var/packages/$SYNOPKG_PKGNAME/etc/image -decrypt < /var/packages/$SYNOPKG_PKGNAME/etc/backup)
fi
fi
sudo /bin/unlink "$LINK"
# Unlink nginx configuration
LogInfo "Removing nginx Link"
ExecSSH "$MODS_ADMIN" "$MODS_PASSWORD" "$MODS_PORT" "unlink $LINK"
ExitCode=$?
if [ $ExitCode != 0 ]; then
if [ -f $LINK ]; then
PublishInfo
PublishInfo "Couldn't remove the link '$Link'."
PublishInfo "This is not a blocking issue but uninstallation is not clean."

View File

@ -5,8 +5,16 @@
StartScript
LinkNginx
ExitCode=$?
EnableRouterLog
if [ $ExitCode == "0" ]; then
EnableRouterLog
fi
EndScript
exit 0
if [ $ExitCode == "0" ]; then
exit 0
else
exit 150
fi