This commit is contained in:
2021-08-24 14:35:11 +03:00
parent d8fba9335d
commit 4f37cb59b1
107 changed files with 3941 additions and 66 deletions

View File

@@ -0,0 +1,16 @@
# Changelog
## 1.2.1
- bump hassio-addon-base to V10.0.1
## 1.2.0
- bump hassio-addon-base to V10.0.0
## 1.1.1
- Added the option to submit up to three arguments to the scripts
## 1.1.0
- Added the option to submit up to two arguments to the scripts
## 1.0.0
- Initial release

View File

@@ -0,0 +1,14 @@
ARG BUILD_FROM=ghcr.io/hassio-addons/base/amd64:10.0.1
# hadolint ignore=DL3006
FROM ${BUILD_FROM}
ENV LANG C.UTF-8
# Create directory for apache2 to store PID file
RUN mkdir /run/apache2
RUN apk --no-cache add busybox-extras curl grep coreutils sed xmlstarlet bash
# Copy data for add-on
COPY run.sh /
RUN chmod a+x /run.sh
CMD [ "/run.sh" ]

View File

@@ -0,0 +1,126 @@
# Home Assistant Community Add-on: Bash Script Executer
![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] ![Supports i386 Architecture][i386-shield]
![Project Maintenance][maintenance-shield]
Bash Script Executer for Homeassistant OS
## About
This is a simple Docker Image to execute personal scripts. The reason I am needing this, is that the HA OS has limited features installed (for example no curl, sed etc) and this Addon fixes that issue.<br />
You can run up to three different scripts with this addon.<br />
This docker image comes with: busybox-extras curl grep coreutils sed xmlstarlet
## Installation
[![FaserF Homeassistant Addons](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2FFaserF%2Fhassio-addons)
<br />
The installation of this add-on is pretty straightforward and not different in comparison to installing any other custom Home Assistant add-on.<br />
Just click the link above or add my repo to the hassio addons repositorys: https://github.com/FaserF/hassio-addons
Put your scripts somewhere in the /share/ folder. Other folders are not visible to this addon.<br />
Example File where your script could be: /share/scripts/script.sh
## Configuration
**I am recommending to disable "Start on boot" and the Watchdog option from HA for this addon!**<br />
**Note**: _Remember to restart the add-on when the configuration is changed._
Example add-on configuration:
```yaml
script_path: /share/scripts/script.sh
script_argument1: myFirstArgument
script_argument2: AnotherVariable
script_argument3: AnotherVariable
script_path2: false
script2_argument1:
script2_argument2:
script2_argument3:
script_path3: false
script3_argument2:
script3_argument2:
script3_argument3:
```
**Note**: _This is just an example, don't copy and paste it! Create your own!_
### Option: `script_path`
This option is needed. Change it depending where your script is or change it to "false" to leave it empty.
### Option: `scriptX_argumentX`
This option is optional. You can submit up to three arguments to your script with this option.
### Option: `script_path2`
This option is needed. Change it depending where your script is or change it to "false" to leave it empty.
### Option: `script_path3`
This option is needed. Change it depending where your script is or change it to "false" to leave it empty.
## Cron Support - running scripts by time
I havent implemented Cron in this addon, as you can run your scripts periodically by an Homeassistant automation.
Example Automation: <br />
```yaml
- alias: "Run Bash Script with Addon Bash Script Executer"
trigger:
- platform: time
at: '00:02:00'
- platform: time_pattern
minutes: '/90'
seconds: 0
action:
- service: hassio.addon_start
data:
addon: 605cee21_bashscriptexecuter
```
## Support
Got questions or problems?
You can [open an issue here][issue] GitHub.
Please keep in mind, that this software is only tested on armv7 running on a Raspberry Pi 4. And that I have made this addon for my personal scripts.
## Authors & contributors
The hassio addon is brought to you by [FaserF].
## License
MIT License
Copyright (c) 2021 FaserF
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[maintenance-shield]: https://img.shields.io/maintenance/yes/2021.svg
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg
[i386-shield]: https://img.shields.io/badge/i386-yes-green.svg
[FaserF]: https://github.com/FaserF/
[issue]: https://github.com/FaserF/hassio-addons/issues
[repository]: https://github.com/FaserF/hassio-addons/bash_script_executer

View File

@@ -0,0 +1,9 @@
{
"build_from": {
"aarch64": "ghcr.io/hassio-addons/base/aarch64:10.0.1",
"amd64": "ghcr.io/hassio-addons/base/amd64:10.0.1",
"armhf": "ghcr.io/hassio-addons/base/armhf:10.0.1",
"armv7": "ghcr.io/hassio-addons/base/armv7:10.0.1",
"i386": "ghcr.io/hassio-addons/base/i386:10.0.1"
}
}

View File

@@ -0,0 +1,31 @@
{
"name": "Bash Script Executer",
"version": "1.2.1",
"slug": "bashscriptexecuter",
"description": "Execute your own bash scripts via Docker Container",
"url": "https://github.com/FaserF/hassio-addons/tree/master/bash_script_executer",
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
"startup": "application",
"boot": "auto",
"map": ["share:rw"],
"panel_icon": "mdi:web-box",
"options": {
"script_path": "/share/scripts/mycoolscript.sh",
"script_path2": "false",
"script_path3": "false"
},
"schema": {
"script_path":"str",
"script_argument1":"str?",
"script_argument2":"str?",
"script_argument3":"str?",
"script_path2":"str",
"script2_argument1":"str?",
"script2_argument2":"str?",
"script2_argument3":"str?",
"script_path3":"str",
"script3_argument1":"str?",
"script3_argument2":"str?",
"script3_argument3":"str?"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@@ -0,0 +1,70 @@
#!/usr/bin/env bashio
script_path=$(bashio::config 'script_path')
script_argument1=$(bashio::config 'script_argument1')
script_argument2=$(bashio::config 'script_argument2')
script_argument3=$(bashio::config 'script_argument3')
script_path2=$(bashio::config 'script_path2')
script2_argument1=$(bashio::config 'script2_argument1')
script2_argument2=$(bashio::config 'script2_argument2')
script2_argument3=$(bashio::config 'script2_argument3')
script_path3=$(bashio::config 'script_path3')
script3_argument1=$(bashio::config 'script3_argument1')
script3_argument2=$(bashio::config 'script3_argument2')
script3_argument3=$(bashio::config 'script3_argument3')
if [ $script_path != "false" ]; then
if [ ! -f $script_path ]; then
echo "Cant find your first script at $script_path"
echo "Exiting now..."
exit 1
fi
fi
if [ $script_path2 != "false" ]; then
if [ ! -f $script_path2 ]; then
echo "Cant find your second script at $script_path2"
echo "Exiting now..."
exit 1
fi
fi
if [ $script_path3 != "false" ]; then
if [ ! -f $script_path3 ]; then
echo "Cant find your third script at $script_path3"
echo "Exiting now..."
exit 1
fi
fi
#Set 711 rights to script
echo "Fixing permissions."
if [ $script_path != "false" ]; then
find $script_path -type d -exec chmod 711 {} \;
fi
if [ $script_path2 != "false" ]; then
find $script_path2 -type d -exec chmod 711 {} \;
fi
if [ $script_path3 != "false" ]; then
find $script_path3 -type d -exec chmod 711 {} \;
fi
if [ $script_path != "false" ]; then
echo "Executing the first script $script_path with the argument $script_argument1 and the second argument $script_argument2 and the third argument $script_argument3 now..."
echo "-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
bash $script_path $script_argument1 $script_argument2 $script_argument3
fi
if [ $script_path2 != "false" ]; then
echo "Executing the second script $script_path2 with the argument $script2_argument1 and the second argument $script2_argument2 and the third argument $script2_argument3 now..."
echo "-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
bash $script_path2 $script2_argument2 $script2_argument3
fi
if [ $script_path3 != "false" ]; then
echo "Executing the third script $script_path3 with the argument $script3_argument1 and the second argument $script3_argument2 and the third argument $script3_argument3 now..."
echo "-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
bash $script_path3 $script3_argument1 $script3_argument2 $script3_argument3
fi
echo "-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
echo "All Scripts were executed. Stopping container..."