vigil

Security camera system built on motion and yolov7.
Log | Files | Refs

commit 4269beee3ba324e5bab2033c8b7bd413379e281b
parent 8024b1df13c793af2810afeb86f8467d85f6681b
Author: dwrz <dwrz@dwrz.net>
Date:   Thu,  2 Feb 2023 14:46:35 +0000

Refactor setup script

Diffstat:
Msetup | 53+++++++++++++++++++++++++++++++++++------------------
1 file changed, 35 insertions(+), 18 deletions(-)

diff --git a/setup b/setup @@ -12,7 +12,7 @@ readonly FILES=( B2_BUCKET="my-bucket-name" CAMERA_NAME="Kitchen" -DOMAIN="kitchen.example.com" +DOMAIN="${HOSTNAME}" EMAIL_HOST="smtp.gmail.com" EMAIL_PORT="587" EMAIL_USER="user@example.com" @@ -116,25 +116,34 @@ print_settings() { write_settings() { for f in "${FILES[@]}"; do - sed -i "s/\${B2_BUCKET}/${B2_BUCKET}/g" "${f}" - sed -i "s/\${CAMERA_NAME}/${CAMERA_NAME}/g" "${f}" - sed -i "s/\${DOMAIN}/${DOMAIN}/g" "${f}" - sed -i "s/\${EMAIL_HOST}/${EMAIL_HOST}/g" "${f}" - sed -i "s/\${EMAIL_PASSWORD}/${EMAIL_PASSWORD}/g" "${f}" - sed -i "s/\${EMAIL_PORT}/${EMAIL_PORT}/g" "${f}" - sed -i "s/\${EMAIL_USER}/${EMAIL_USER}/g" "${f}" - sed -i "s/\${MOTION_DIR}/${MOTION_DIR}/g" "${f}" - sed -i "s/\${MOTION_LOG_FILE}/${MOTION_LOG_FILE}/g" "${f}" - sed -i "s/\${MOTION_PASSWORD}/${MOTION_PASSWORD}/g" "${f}" - sed -i "s/\${MOTION_USER}/${MOTION_USER}/g" "${f}" - sed -i "s/\${NOTIFICATION_RECIPIENT}/${NOTIFICATION_RECIPIENT}/g" "${f}" - sed -i "s/\${PORT_CONTROL}/${PORT_CONTROL}/g" "${f}" - sed -i "s/\${PORT_STREAM}/${PORT_STREAM}/g" "${f}" - sed -i "s/\${TLS_CERT}/${TLS_CERT}/g" "${f}" - sed -i "s/\${TLS_KEY}/${TLS_KEY}/g" "${f}" + sed -i 's|\${B2_BUCKET}|'"${B2_BUCKET}"'|g' "${f}" + sed -i 's|\${CAMERA_NAME}|'"${CAMERA_NAME}"'|g' "${f}" + sed -i 's|\${DOMAIN}|'"${DOMAIN}"'|g' "${f}" + sed -i 's|\${EMAIL_HOST}|'"${EMAIL_HOST}"'|g' "${f}" + sed -i 's|\${EMAIL_PASSWORD}|'"${EMAIL_PASSWORD}"'|g' "${f}" + sed -i 's|\${EMAIL_PORT}|'"${EMAIL_PORT}"'|g' "${f}" + sed -i 's|\${EMAIL_USER}|'"${EMAIL_USER}"'|g' "${f}" + sed -i 's|\${MOTION_DIR}|'"${MOTION_DIR}"'|g' "${f}" + sed -i 's|\${MOTION_LOG_FILE}|'"${MOTION_LOG_FILE}"'|g' "${f}" + sed -i 's|\${MOTION_PASSWORD}|'"${MOTION_PASSWORD}"'|g' "${f}" + sed -i 's|\${MOTION_USER}|'"${MOTION_USER}"'|g' "${f}" + sed -i 's|\${NOTIFICATION_RECIPIENT}|'"${NOTIFICATION_RECIPIENT}"'|g' "${f}" + sed -i 's|\${PORT_CONTROL}|'"${PORT_CONTROL}"'|g' "${f}" + sed -i 's|\${PORT_STREAM}|'"${PORT_STREAM}"'|g' "${f}" + sed -i 's|\${TLS_CERT}|'"${TLS_CERT}"'|g' "${f}" + sed -i 's|\${TLS_KEY}|'"${TLS_KEY}"'|g' "${f}" done } +link_files() { + ln -s "./config/motion.conf" "/etc/motion/motion.conf" + ln -s "./config/msmtprc" "${MOTION_DIR}/.msmtprc" + ln -s "./config/muttrc" "${MOTION_DIR}/.muttrc" + ln -s "./scripts/alert" "${MOTION_DIR}/alert" + ln -s "./scripts/notify" "${MOTION_DIR}/notify" + ln -s "./scripts/sync" "${MOTION_DIR}/sync" +} + main() { input_settings @@ -143,7 +152,15 @@ main() { echo "Update files?" select yn in "yes" "no"; do case "${yn}" in - yes ) write_settings && exit 0 ;; + yes ) write_settings ;; + no ) exit 0 ;; + esac + done + + echo "Link files?" + select yn in "yes" "no"; do + case "${yn}" in + yes ) link_files && exit 0 ;; no ) exit 0 ;; esac done