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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from ludeeus/hassbian-manager
Adds hassbian manager script
- Loading branch information
Showing
4 changed files
with
169 additions
and
0 deletions.
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
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,43 @@ | ||
# Hassbian manager | ||
|
||
Hassbian manager is a web UI tool that can help you manage your suites. | ||
|
||
When installed the WEB UI are running on port `9999` | ||
|
||
## Installation | ||
|
||
```bash | ||
sudo hassbian-config install manager | ||
``` | ||
|
||
## Upgrade | ||
|
||
```bash | ||
sudo hassbian-config upgrade manager | ||
``` | ||
|
||
## Remove to beta channel | ||
|
||
```bash | ||
sudo hassbian-config remoev manager | ||
``` | ||
|
||
## Additional info | ||
|
||
Description | Command/value | ||
:--- | :--- | ||
Running as: | homeassistant | ||
Default user: | `pi` | ||
Default password: | `raspberry` | ||
Port: | `9999` | ||
Start service: | `sudo systemctl start hassbian-manager@homeassistant.service` | ||
Stop service: | `sudo systemctl stop hassbian-manager@homeassistant.service` | ||
Restart service: | `sudo systemctl restart hassbian-manager@homeassistant.service` | ||
Service status: | `sudo systemctl status hassbian-manager@homeassistant.service` | ||
|
||
*** | ||
|
||
The script was originally contributed by [@Ludeeus][ludeeus]. | ||
|
||
<!--- Links ---> | ||
[ludeeus]: https://github.com/ludeeus |
16 changes: 16 additions & 0 deletions
16
package/opt/hassbian/suites/files/hassbian-manager@homeassistant.service
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 @@ | ||
# | ||
# Service file for systems with systemd to run Hassbian manager as the homeassistant user. | ||
# | ||
|
||
[Unit] | ||
Description=Hassbian manager for %i | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
User=%i | ||
ExecStart=/usr/local/bin/pyhassbian --username %%USERNAME%% --password %%PASSWORD%% | ||
SendSIGKILL=no | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,109 @@ | ||
#!/bin/bash | ||
function manager-show-short-info { | ||
echo "Hassbian manager script." | ||
} | ||
|
||
function manager-show-long-info { | ||
echo "Hassbian manager is a web UI tool that can help you manage your suites." | ||
} | ||
|
||
function manager-show-copyright-info { | ||
echo "Original concept by Ludeeus <https://github.com/ludeeus>." | ||
} | ||
|
||
function manager-install-package { | ||
|
||
if [ "$ACCEPT" == "true" ]; then | ||
username=pi | ||
password=raspberry | ||
else | ||
echo | ||
echo "Please take a moment to setup your the user account" | ||
echo | ||
|
||
echo -n "Username: " | ||
read -r username | ||
if [ ! "$username" ]; then | ||
username=pi | ||
fi | ||
|
||
echo -n "Password: " | ||
read -s -r password | ||
echo | ||
if [ ! "$password" ]; then | ||
password=raspberry | ||
fi | ||
fi | ||
|
||
echo "Installing latest version of Hassbian manager" | ||
python3 -m pip install setuptools wheel | ||
python3 -m pip install pyhassbian | ||
|
||
|
||
echo "Enabling Hassbian manager service" | ||
cp /opt/hassbian/suites/files/hassbian-manager@homeassistant.service /etc/systemd/system/hassbian-manager@homeassistant.service | ||
|
||
sed -i "s,%%USERNAME%%,${username},g" /etc/systemd/system/hassbian-manager@homeassistant.service | ||
sed -i "s,%%PASSWORD%%,${password},g" /etc/systemd/system/hassbian-manager@homeassistant.service | ||
|
||
systemctl enable hassbian-manager@homeassistant.service | ||
sync | ||
|
||
echo "Starting Hassbian manager" | ||
systemctl start hassbian-manager@homeassistant.service | ||
|
||
ip_address=$(ifconfig | grep "inet.*broadcast" | grep -v 0.0.0.0 | awk '{print $2}') | ||
|
||
echo "Checking the installation..." | ||
validation=$(pgrep -x pyhassbian) | ||
if [ ! -z "${validation}" ]; then | ||
echo | ||
echo -e "\\e[32mInstallation done..\\e[0m" | ||
echo "Hassbian manager installation is running at $ip_address:9999 or if preferred http://hassbian.local:9999" | ||
echo | ||
echo | ||
else | ||
echo | ||
echo -e "\\e[31mInstallation failed..." | ||
echo | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
function manager-upgrade-package { | ||
echo "Upgrading Hassbian manager" | ||
python3 -m pip install --upgrade pyhassbian | ||
|
||
echo "Restarting Hassbian manager" | ||
systemctl start hassbian-manager@homeassistant.service | ||
|
||
echo "Checking the installation..." | ||
validation=$(pgrep -x pyhassbian) | ||
if [ ! -z "${validation}" ]; then | ||
echo | ||
echo -e "\\e[32mUpgrade script completed..\\e[0m" | ||
echo | ||
else | ||
echo | ||
echo -e "\\e[31mUpgrade failed..." | ||
echo | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
function manager-remove-package { | ||
printf "Removing Hassbian manager...\\n" | ||
systemctl stop hassbian-manager@homeassistant.service | ||
systemctl disable hassbian-manager@homeassistant.service | ||
rm /etc/systemd/system/hassbian-manager@homeassistant.service | ||
sync | ||
|
||
echo "Removing Hassbian manager" | ||
python3 -m pip uninstall --yes pyhassbian | ||
|
||
printf "\\e[32mRemoval done..\\e[0m\\n" | ||
} | ||
|
||
[[ "$_" == "$0" ]] && echo "hassbian-config helper script; do not run directly, use hassbian-config instead" |