-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial scaffold for install wizard. untested * first working draft * moves scripts from root into seperate folder * Adds description in README.md
- Loading branch information
Showing
21 changed files
with
175 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
install: | ||
## check if vars are set | ||
bash ./install_scripts/check_vars.sh GOPATH | ||
## run go install | ||
go install ./... | ||
## create system-wide symlink to executables | ||
bash ./install_scripts/create_symlinks.sh motion-poll set-preset goto-preset set-time | ||
## create config folder | ||
bash ./install_scripts/create_service_templates.sh | ||
|
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,18 @@ | ||
#!/bin/bash | ||
function check_var { | ||
declare -n var_ref=$1 | ||
declared=$? | ||
if [ "$declared" != 0 ] | ||
then | ||
echo "$var_ref must be set! Exiting!" | ||
exit 1 | ||
fi | ||
} | ||
|
||
for var in "$@" | ||
do | ||
echo "checking $var is set" | ||
check_var "$var" | ||
done | ||
|
||
|
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,17 @@ | ||
#!/bin/bash | ||
|
||
read -r -p "Path for configuration folder [~/.config/onvif-cam-poll]" $CONFIG_PATH | ||
export CONFIG_PATH=${config_path:-~/.config/onvif-cam-poll} | ||
echo "$CONFIG_PATH" | ||
mkdir --p "$CONFIG_PATH" | ||
export CONFIG_PATH | ||
## create service templates | ||
cp ./services/* "$CONFIG_PATH"/. | ||
envsubst < "$CONFIG_PATH"/[email protected] > "$CONFIG_PATH"/[email protected] && mv "$CONFIG_PATH"/[email protected] "$CONFIG_PATH"/[email protected] | ||
envsubst < "$CONFIG_PATH"/[email protected] > "$CONFIG_PATH"/[email protected] && mv "$CONFIG_PATH"/[email protected] "$CONFIG_PATH"/[email protected] | ||
sudo cp "$CONFIG_PATH"/*.service /lib/systemd/system/. | ||
sudo systemctl daemon-reload | ||
echo "To track a new camera create an .env file for it in $CONFIG_PATH" | ||
echo "Fill in all the variables that are listed in the example.env file" | ||
echo "Afterwards, run systemctl start motion@camera_envfile_name" | ||
echo "Don't forget to enable the service if you want it to run after a restart" |
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,10 @@ | ||
function create_symlink() { | ||
sudo rm "/usr/bin/$1" | ||
sudo ln -s "$GOPATH/$1" "/usr/bin/$1" | ||
} | ||
|
||
for var in "$@" | ||
do | ||
echo "creating symlink for $var" | ||
create_symlink "$var" | ||
done |
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 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
EnvironmentFile=/home/isaric/.config/onvif-cam-poll/%i.env | ||
Restart=always | ||
RestartSec=3 | ||
User=isaric | ||
Group=isaric | ||
ExecStart=/bin/bash /home/isaric/.config/onvif-cam-poll/motion.sh | ||
TimeoutStartSec=0 | ||
|
||
[Install] | ||
WantedBy=default.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,6 @@ | ||
CAMERA_ADDRESS=bla.bla.bla:8899 | ||
CAMERA_USER=admin | ||
CAMERA_PASSWORD=xxxxxx | ||
CAMERA_NAME=garage | ||
SLACK_BOT_TOKEN=xoxb-xxxxxx-xxxxxx-xxxxxx | ||
SLACK_CHANNEL_ID=xxxxxx |
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 @@ | ||
motion-poll -a ${CAMERA_ADDRESS} -u ${CAMERA_USER} -p ${CAMERA_PASSWORD} -n ${CAMERA_NAME} -s ${SLACK_WEBHOOK} -t 30 -b ${SLACK_BOT_TOKEN} -c ${SLACK_CHANNEL_ID} |
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 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
EnvironmentFile=$path/%i.env | ||
Restart=always | ||
RestartSec=3 | ||
User=$SUDO_USER | ||
Group=$SUDO_USER | ||
ExecStart=/bin/bash $path/motion.sh | ||
TimeoutStartSec=0 | ||
|
||
[Install] | ||
WantedBy=default.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 @@ | ||
set-time -a ${CAMERA_ADDRESS} -u admin -p ${CAMERA_PASSWORD} |
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 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
EnvironmentFile=$path/%i.env | ||
Restart=always | ||
RestartSec=3 | ||
User=$SUDO_USER | ||
Group=$SUDO_USER | ||
ExecStart=/bin/bash $path/time.sh | ||
TimeoutStartSec=0 | ||
|
||
[Install] | ||
WantedBy=default.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
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 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
EnvironmentFile=${CONFIG_PATH}/%i.env | ||
Restart=always | ||
RestartSec=3 | ||
User=${USER} | ||
Group=${USER} | ||
ExecStart=/bin/bash ${CONFIG_PATH}/goto.sh | ||
TimeoutStartSec=0 | ||
|
||
[Install] | ||
WantedBy=default.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 @@ | ||
goto-preset -a ${CAMERA_ADDRESS} -u ${CAMERA_USER} -p ${CAMERA_PASSWORD} -t 30 -l 001 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
/path/to/motion-poll -a ${CAMERA_ADDRESS} -u ${CAMERA_USER} -p ${CAMERA_PASSWORD} -n ${CAMERA_NAME} -s ${SLACK_WEBHOOK} -t 30 -b ${SLACK_BOT_TOKEN} -c ${SLACK_CHANNEL_ID} | ||
motion-poll -a ${CAMERA_ADDRESS} -u ${CAMERA_USER} -p ${CAMERA_PASSWORD} -n ${CAMERA_NAME} -s ${SLACK_WEBHOOK} -t 30 -b ${SLACK_BOT_TOKEN} -c ${SLACK_CHANNEL_ID} |
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 @@ | ||
set-preset -a ${CAMERA_ADDRESS} -u ${CAMERA_USER} -p ${CAMERA_PASSWORD} -l 001 |
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 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
EnvironmentFile=${CONFIG_PATH}/%i.env | ||
Restart=always | ||
RestartSec=3 | ||
User=${USER} | ||
Group=${USER} | ||
ExecStart=/bin/bash ${CONFIG_PATH}/set-preset.sh | ||
TimeoutStartSec=0 | ||
|
||
[Install] | ||
WantedBy=default.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 |
---|---|---|
@@ -1 +1 @@ | ||
/path/to/set-time -a ${CAMERA_ADDRESS} -u admin -p ${CAMERA_PASSWORD} | ||
set-time -a ${CAMERA_ADDRESS} -u admin -p ${CAMERA_PASSWORD} |
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,16 @@ | ||
[Unit] | ||
DefaultDependencies=no | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
EnvironmentFile=/home/isaric/.config/onvif-cam-poll/%i.env | ||
Restart=always | ||
RestartSec=3 | ||
User=isaric | ||
Group=isaric | ||
ExecStart=/bin/bash /home/isaric/.config/onvif-cam-poll/time.sh | ||
TimeoutStartSec=0 | ||
|
||
[Install] | ||
WantedBy=default.target |