Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
cc692854
Unverified
Commit
cc692854
authored
Dec 09, 2020
by
Thijn
Committed by
Brian Hartvigsen
Dec 09, 2020
Browse files
Fix synology_dsm deployhook for DSM 7
parent
99d3a283
Changes
1
Show whitespace changes
Inline
Side-by-side
deploy/synology_dsm.sh
View file @
cc692854
...
@@ -73,13 +73,25 @@ synology_dsm_deploy() {
...
@@ -73,13 +73,25 @@ synology_dsm_deploy() {
_base_url
=
"
$SYNO_Scheme
://
$SYNO_Hostname
:
$SYNO_Port
"
_base_url
=
"
$SYNO_Scheme
://
$SYNO_Hostname
:
$SYNO_Port
"
_debug _base_url
"
$_base_url
"
_debug _base_url
"
$_base_url
"
_debug
"Getting API version"
response
=
$(
_get
"
$_base_url
/webapi/query.cgi?api=SYNO.API.Info&version=1&method=query&query=SYNO.API.Auth"
)
api_version
=
$(
echo
"
$response
"
|
grep
"SYNO.API.Auth"
|
sed
-n
's/.*"maxVersion" *: *\([0-9]*\).*/\1/p'
)
_debug3 response
"
$response
"
_debug3 api_version
"
$api_version
"
# Login, get the token from JSON and session id from cookie
# Login, get the token from JSON and session id from cookie
_info
"Logging into
$SYNO_Hostname
:
$SYNO_Port
"
_info
"Logging into
$SYNO_Hostname
:
$SYNO_Port
"
encoded_username
=
"
$(
printf
"%s"
"
$SYNO_Username
"
| _url_encode
)
"
encoded_username
=
"
$(
printf
"%s"
"
$SYNO_Username
"
| _url_encode
)
"
encoded_password
=
"
$(
printf
"%s"
"
$SYNO_Password
"
| _url_encode
)
"
encoded_password
=
"
$(
printf
"%s"
"
$SYNO_Password
"
| _url_encode
)
"
encoded_did
=
"
$(
printf
"%s"
"
$SYNO_DID
"
| _url_encode
)
"
response
=
$(
_post
"username=
$encoded_username
&passwd=
$encoded_password
&device_id=
$encoded_did
"
"
$_base_url
/webman/login.cgi?enable_syno_token=yes"
)
if
[
!
-z
"
$SYNO_DID
"
]
;
then
token
=
$(
echo
"
$response
"
|
grep
"SynoToken"
|
sed
-n
's/.*"SynoToken" *: *"\([^"]*\).*/\1/p'
)
_H1
=
"Cookie: did=
$SYNO_DID
"
export
_H1
_debug3 H1
"
${
_H1
}
"
fi
response
=
$(
_post
"method=login&account=
$encoded_username
&passwd=
$encoded_password
&enable_device_token=yes&enable_syno_token=yes"
"
$_base_url
/webapi/entry.cgi?api=SYNO.API.Auth&version=
$api_version
"
)
token
=
$(
echo
"
$response
"
|
grep
"synotoken"
|
sed
-n
's/.*"synotoken" *: *"\([^"]*\).*/\1/p'
)
_debug3 response
"
$response
"
_debug3 response
"
$response
"
_debug token
"
$token
"
_debug token
"
$token
"
...
@@ -88,13 +100,11 @@ synology_dsm_deploy() {
...
@@ -88,13 +100,11 @@ synology_dsm_deploy() {
_err
"Check your username and password."
_err
"Check your username and password."
return
1
return
1
fi
fi
sid
=
$(
echo
"
$response
"
|
grep
"sid"
|
sed
-n
's/.*"sid" *: *"\([^"]*\).*/\1/p'
)
_H1
=
"Cookie:
$(
_syno_get_cookie_data
"id"
)
;
$(
_syno_get_cookie_data
"smid"
)
"
_H1
=
"X-SYNO-TOKEN:
$token
"
_H2
=
"X-SYNO-TOKEN:
$token
"
export
_H1
export
_H1
export
_H2
_debug2 H1
"
${
_H1
}
"
_debug2 H1
"
${
_H1
}
"
_debug2 H2
"
${
_H2
}
"
# Now that we know the username and password are good, save them
# Now that we know the username and password are good, save them
_savedeployconf SYNO_Username
"
$SYNO_Username
"
_savedeployconf SYNO_Username
"
$SYNO_Username
"
...
@@ -102,7 +112,7 @@ synology_dsm_deploy() {
...
@@ -102,7 +112,7 @@ synology_dsm_deploy() {
_savedeployconf SYNO_DID
"
$SYNO_DID
"
_savedeployconf SYNO_DID
"
$SYNO_DID
"
_info
"Getting certificates in Synology DSM"
_info
"Getting certificates in Synology DSM"
response
=
$(
_post
"api=SYNO.Core.Certificate.CRT&method=list&version=1"
"
$_base_url
/webapi/entry.cgi"
)
response
=
$(
_post
"api=SYNO.Core.Certificate.CRT&method=list&version=1
&_sid=
$sid
"
"
$_base_url
/webapi/entry.cgi"
)
_debug3 response
"
$response
"
_debug3 response
"
$response
"
id
=
$(
echo
"
$response
"
|
sed
-n
"s/.*
\"
desc
\"
:
\"
$SYNO_Certificate
\"
,
\"
id
\"
:
\"\(
[^
\"
]*
\)
.*/
\1
/p"
)
id
=
$(
echo
"
$response
"
|
sed
-n
"s/.*
\"
desc
\"
:
\"
$SYNO_Certificate
\"
,
\"
id
\"
:
\"\(
[^
\"
]*
\)
.*/
\1
/p"
)
_debug2
id
"
$id
"
_debug2
id
"
$id
"
...
@@ -135,7 +145,7 @@ synology_dsm_deploy() {
...
@@ -135,7 +145,7 @@ synology_dsm_deploy() {
content
=
"
${
content
%_
}
"
# protect trailing \n
content
=
"
${
content
%_
}
"
# protect trailing \n
_info
"Upload certificate to the Synology DSM"
_info
"Upload certificate to the Synology DSM"
response
=
$(
_post
"
$content
"
"
$_base_url
/webapi/entry.cgi?api=SYNO.Core.Certificate&method=import&version=1&SynoToken=
$token
"
""
"POST"
"multipart/form-data; boundary=
${
delim
}
"
)
response
=
$(
_post
"
$content
"
"
$_base_url
/webapi/entry.cgi?api=SYNO.Core.Certificate&method=import&version=1&SynoToken=
$token
&_sid=
$sid
"
""
"POST"
"multipart/form-data; boundary=
${
delim
}
"
)
_debug3 response
"
$response
"
_debug3 response
"
$response
"
if
!
echo
"
$response
"
|
grep
'"error":'
>
/dev/null
;
then
if
!
echo
"
$response
"
|
grep
'"error":'
>
/dev/null
;
then
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment