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
b1bf6341
Unverified
Commit
b1bf6341
authored
Jan 07, 2022
by
neil
Committed by
GitHub
Jan 07, 2022
Browse files
Merge pull request #3876 from fraenki/fix_fritz
deploy/fritzbox: allow hook to be used with multiple fritzboxes
parents
0727f705
6aa1ec08
Changes
1
Hide whitespace changes
Inline
Side-by-side
deploy/fritzbox.sh
View file @
b1bf6341
...
@@ -36,43 +36,51 @@ fritzbox_deploy() {
...
@@ -36,43 +36,51 @@ fritzbox_deploy() {
fi
fi
fi
fi
_fritzbox_username
=
"
${
DEPLOY_FRITZBOX_USERNAME
}
"
# Clear traces of incorrectly stored values
_fritzbox_password
=
"
${
DEPLOY_FRITZBOX_PASSWORD
}
"
_clearaccountconf DEPLOY_FRITZBOX_USERNAME
_fritzbox_url
=
"
${
DEPLOY_FRITZBOX_URL
}
"
_clearaccountconf DEPLOY_FRITZBOX_PASSWORD
_clearaccountconf DEPLOY_FRITZBOX_URL
_debug _fritzbox_url
"
$_fritzbox_url
"
_debug _fritzbox_username
"
$_fritzbox_username
"
# Read config from saved values or env
_secure_debug _fritzbox_password
"
$_fritzbox_password
"
_getdeployconf DEPLOY_FRITZBOX_USERNAME
if
[
-z
"
$_fritzbox_username
"
]
;
then
_getdeployconf DEPLOY_FRITZBOX_PASSWORD
_getdeployconf DEPLOY_FRITZBOX_URL
_debug DEPLOY_FRITZBOX_URL
"
$DEPLOY_FRITZBOX_URL
"
_debug DEPLOY_FRITZBOX_USERNAME
"
$DEPLOY_FRITZBOX_USERNAME
"
_secure_debug DEPLOY_FRITZBOX_PASSWORD
"
$DEPLOY_FRITZBOX_PASSWORD
"
if
[
-z
"
$DEPLOY_FRITZBOX_USERNAME
"
]
;
then
_err
"FRITZ!Box username is not found, please define DEPLOY_FRITZBOX_USERNAME."
_err
"FRITZ!Box username is not found, please define DEPLOY_FRITZBOX_USERNAME."
return
1
return
1
fi
fi
if
[
-z
"
$
_fritzbox_password
"
]
;
then
if
[
-z
"
$
DEPLOY_FRITZBOX_PASSWORD
"
]
;
then
_err
"FRITZ!Box password is not found, please define DEPLOY_FRITZBOX_PASSWORD."
_err
"FRITZ!Box password is not found, please define DEPLOY_FRITZBOX_PASSWORD."
return
1
return
1
fi
fi
if
[
-z
"
$
_fritzbox_url
"
]
;
then
if
[
-z
"
$
DEPLOY_FRITZBOX_URL
"
]
;
then
_err
"FRITZ!Box url is not found, please define DEPLOY_FRITZBOX_URL."
_err
"FRITZ!Box url is not found, please define DEPLOY_FRITZBOX_URL."
return
1
return
1
fi
fi
_saveaccountconf DEPLOY_FRITZBOX_USERNAME
"
${
_fritzbox_username
}
"
# Save current values
_saveaccountconf DEPLOY_FRITZBOX_PASSWORD
"
${
_fritzbox_password
}
"
_savedeployconf DEPLOY_FRITZBOX_USERNAME
"
$DEPLOY_FRITZBOX_USERNAME
"
_saveaccountconf DEPLOY_FRITZBOX_URL
"
${
_fritzbox_url
}
"
_savedeployconf DEPLOY_FRITZBOX_PASSWORD
"
$DEPLOY_FRITZBOX_PASSWORD
"
_savedeployconf DEPLOY_FRITZBOX_URL
"
$DEPLOY_FRITZBOX_URL
"
# Do not check for a valid SSL certificate, because initially the cert is not valid, so it could not install the LE generated certificate
# Do not check for a valid SSL certificate, because initially the cert is not valid, so it could not install the LE generated certificate
export
HTTPS_INSECURE
=
1
export
HTTPS_INSECURE
=
1
_info
"Log in to the FRITZ!Box"
_info
"Log in to the FRITZ!Box"
_fritzbox_challenge
=
"
$(
_get
"
${
_fritzbox_url
}
/login_sid.lua"
|
sed
-e
's/^.*<Challenge>//'
-e
's/<\/Challenge>.*$//'
)
"
_fritzbox_challenge
=
"
$(
_get
"
${
DEPLOY_FRITZBOX_URL
}
/login_sid.lua"
|
sed
-e
's/^.*<Challenge>//'
-e
's/<\/Challenge>.*$//'
)
"
if
_exists iconv
;
then
if
_exists iconv
;
then
_fritzbox_hash
=
"
$(
printf
"%s-%s"
"
${
_fritzbox_challenge
}
"
"
${
_fritzbox_password
}
"
| iconv
-f
ASCII
-t
UTF16LE | _digest md5 hex
)
"
_fritzbox_hash
=
"
$(
printf
"%s-%s"
"
${
_fritzbox_challenge
}
"
"
${
DEPLOY_FRITZBOX_PASSWORD
}
"
| iconv
-f
ASCII
-t
UTF16LE | _digest md5 hex
)
"
elif
_exists uconv
;
then
elif
_exists uconv
;
then
_fritzbox_hash
=
"
$(
printf
"%s-%s"
"
${
_fritzbox_challenge
}
"
"
${
_fritzbox_password
}
"
| uconv
-f
ASCII
-t
UTF16LE | _digest md5 hex
)
"
_fritzbox_hash
=
"
$(
printf
"%s-%s"
"
${
_fritzbox_challenge
}
"
"
${
DEPLOY_FRITZBOX_PASSWORD
}
"
| uconv
-f
ASCII
-t
UTF16LE | _digest md5 hex
)
"
else
else
_fritzbox_hash
=
"
$(
printf
"%s-%s"
"
${
_fritzbox_challenge
}
"
"
${
_fritzbox_password
}
"
| perl
-p
-e
'use Encode qw/encode/; print encode("UTF-16LE","$_"); $_="";'
| _digest md5 hex
)
"
_fritzbox_hash
=
"
$(
printf
"%s-%s"
"
${
_fritzbox_challenge
}
"
"
${
DEPLOY_FRITZBOX_PASSWORD
}
"
| perl
-p
-e
'use Encode qw/encode/; print encode("UTF-16LE","$_"); $_="";'
| _digest md5 hex
)
"
fi
fi
_fritzbox_sid
=
"
$(
_get
"
${
_fritzbox_url
}
/login_sid.lua?sid=0000000000000000&username=
${
_fritzbox_username
}
&response=
${
_fritzbox_challenge
}
-
${
_fritzbox_hash
}
"
|
sed
-e
's/^.*<SID>//'
-e
's/<\/SID>.*$//'
)
"
_fritzbox_sid
=
"
$(
_get
"
${
DEPLOY_FRITZBOX_URL
}
/login_sid.lua?sid=0000000000000000&username=
${
DEPLOY_FRITZBOX_USERNAME
}
&response=
${
_fritzbox_challenge
}
-
${
_fritzbox_hash
}
"
|
sed
-e
's/^.*<SID>//'
-e
's/<\/SID>.*$//'
)
"
if
[
-z
"
${
_fritzbox_sid
}
"
]
||
[
"
${
_fritzbox_sid
}
"
=
"0000000000000000"
]
;
then
if
[
-z
"
${
_fritzbox_sid
}
"
]
||
[
"
${
_fritzbox_sid
}
"
=
"0000000000000000"
]
;
then
_err
"Logging in to the FRITZ!Box failed. Please check username, password and URL."
_err
"Logging in to the FRITZ!Box failed. Please check username, password and URL."
...
@@ -104,7 +112,7 @@ fritzbox_deploy() {
...
@@ -104,7 +112,7 @@ fritzbox_deploy() {
_info
"Upload certificate to the FRITZ!Box"
_info
"Upload certificate to the FRITZ!Box"
export
_H1
=
"Content-type: multipart/form-data boundary=
${
_post_boundary
}
"
export
_H1
=
"Content-type: multipart/form-data boundary=
${
_post_boundary
}
"
_post
"
$(
cat
"
${
_post_request
}
"
)
"
"
${
_fritzbox_url
}
/cgi-bin/firmwarecfg"
|
grep
SSL
_post
"
$(
cat
"
${
_post_request
}
"
)
"
"
${
DEPLOY_FRITZBOX_URL
}
/cgi-bin/firmwarecfg"
|
grep
SSL
retval
=
$?
retval
=
$?
if
[
$retval
=
0
]
;
then
if
[
$retval
=
0
]
;
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