This repository has been archived by the owner on Oct 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Webterminal: Added SSL support with existing LE certificates. #130
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2f1d2dc
Added SSL support with existig LE certs
ludeeus d4796d2
Fixes for sticker-ci
ludeeus 1be018b
Updated documentation.
ludeeus 3cadb7f
Specified which domain to use.
ludeeus b0c5059
Added correct protocol
ludeeus d740c1d
Updated cronjob
ludeeus de307b7
Delayed update part 5 min
ludeeus 8c697f7
Changed logic for setting privkey and fullchain
ludeeus bc5c5c8
changed restart to sto start
ludeeus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# Helper script for using LE certificates with Webterminal (shellinabox) | ||
if [ -d "/etc/letsencrypt/live" ]; then | ||
CERTDIR="/etc/letsencrypt/live/" | ||
elif [ -d "/home/homeassistant/dehydrated/certs" ]; then | ||
CERTDIR="/home/homeassistant/dehydrated/certs/" | ||
else | ||
CERTDIR="" | ||
fi | ||
FULLCHAIN=$(find "$CERTDIR" -type f | grep fullchain) | ||
PRIVKEY=$(find "$CERTDIR" -type f | grep privkey) | ||
DOMAIN=$(ls "$CERTDIR") | ||
cat $FULLCHAIN $PRIVKEY > /var/lib/shellinabox/certificate-"$DOMAIN".pem | ||
chown shellinabox:shellinabox -R /var/lib/shellinabox/ | ||
service shellinabox restart | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,53 @@ function webterminal-show-copyright-info { | |
} | ||
|
||
function webterminal-install-package { | ||
|
||
|
||
if [ "$ACCEPT" == "true" ]; then # True if `-y` flag is used. | ||
if [ -d "/etc/letsencrypt/live" ] || [ -d "/home/homeassistant/dehydrated/certs" ]; then | ||
SSL="Y" | ||
else | ||
SSL="N" | ||
fi | ||
else | ||
echo "" | ||
echo -n "Do you use SSL (https) with Home Assistant? [N/y] : " | ||
read -r SSL | ||
if [ ! "$SSL" ]; then | ||
SSL="N" | ||
fi | ||
fi | ||
|
||
echo "Installing packages." | ||
sudo apt-get install -y openssl shellinabox | ||
|
||
echo "Changing config." | ||
sudo sed -i 's/--no-beep/--no-beep --disable-ssl/g' /etc/default/shellinabox | ||
if [ "$SSL" == "y" ] || [ "$SSL" == "Y" ]; then | ||
echo "No need to change default configuration, skipping this step..." | ||
echo "Checking cert directory..." | ||
if [ -d "/etc/letsencrypt/live" ]; then | ||
CERTDIR="/etc/letsencrypt/live/" | ||
elif [ -d "/home/homeassistant/dehydrated/certs" ]; then | ||
CERTDIR="/home/homeassistant/dehydrated/certs/" | ||
else | ||
CERTDIR="" | ||
fi | ||
echo "Setting cert fullchain location..." | ||
FULLCHAIN=$(find "$CERTDIR" -type f | grep fullchain) | ||
echo "Setting cert privkey location..." | ||
PRIVKEY=$(find "$CERTDIR" -type f | grep privkey) | ||
DOMAIN=$(ls "$CERTDIR") | ||
echo "Merging files and adding to correct dir..." | ||
cat $FULLCHAIN $PRIVKEY > /var/lib/shellinabox/certificate-"$DOMAIN".pem | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double quote to prevent globbing and word splitting. |
||
chown shellinabox:shellinabox -R /var/lib/shellinabox/ | ||
echo "Adding crong job to copy certs..." | ||
(crontab -l ; echo "0 1 1 * * bash /opt/hassbian/suites/files/webterminalsslhelper.sh")| crontab - | ||
else | ||
sed -i 's/--no-beep/--no-beep --disable-ssl/g' /etc/default/shellinabox | ||
fi | ||
|
||
echo "Reloading and starting the service." | ||
sudo service shellinabox reload | ||
sudo service shellinabox restart | ||
service shellinabox reload | ||
service shellinabox restart | ||
|
||
ip_address=$(ifconfig | grep "inet.*broadcast" | grep -v 0.0.0.0 | awk '{print $2}') | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double quote to prevent globbing and word splitting.