-
Notifications
You must be signed in to change notification settings - Fork 0
/
installzm.sh
69 lines (66 loc) · 2.16 KB
/
installzm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#Arg Parse from https://betterdev.blog/minimal-safe-bash-script-template/
#justaCasualCoder 2023 - https://github.com/justaCasualCoder
RED='\033[0;31m'
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-d]
Script for installing Zoneminder on Termux
Available options:
-h, --help Print this help and exit
-d, --debug Print script debug info
EOF
exit
}
while :; do
case "${1-}" in
-h | --help) usage ;;
-d | --debug) set -x ;;
-?*) echo "Unknown option: $1" && exit 0 ;;
*) break ;;
esac
shift
done
echo -n "Are you sure you want to install Zoneminder? [y/n]: " ; read yn
[[ -z $yn ]] && echo "Going with defualt : n" && yn=n
if [ $yn != y ]; then
printf "${RED}Aborted\n"
exit 1
fi
apt update
apt install gpgv
apt install apache2 mariadb-server php libapache2-mod-php php-mysql lsb-release gnupg2 -y
/etc/init.d/mariadb start
cat << EOF | mysql
BEGIN;
CREATE DATABASE zm;
CREATE USER zmuser@localhost IDENTIFIED BY 'zmpass';
GRANT ALL ON zm.* TO zmuser@localhost;
FLUSH PRIVILEGES;
EOF
apt install zoneminder -y
mariadb -u zmuser -pzmpass < /usr/share/zoneminder/db/zm_create.sql
chgrp -c www-data /etc/zm/zm.conf
adduser www-data video
a2enconf zoneminder
a2enmod rewrite
a2enmod headers
a2enmod expires
chown www-data:www-data /etc/apache2/conf-available/zoneminder.conf
sed -i 's/80/8080/g' /etc/apache2/ports.conf
/etc/init.d/mariadb restart
/etc/init.d/apache2 start
/etc/init.d/zoneminder start
yn=""
echo -n "Would you like to make Zoneminder start automatically on startup? (just adds the above command to .profile) [y/n]: " ; read yn
[[ -z $yn ]] && echo "Going with defualt : y" && yn=y
if [ $yn == y ]; then
echo "/etc/init.d/apache2 start" >> ~/.profile
echo "/etc/init.d/mariadb start" >> ~/.profile
echo "/etc/init.d/zoneminder start" >> ~/.profile
fi
cd /
yn=""
wget https://raw.githubusercontent.com/justaCasualCoder/Zoneminder-Termux/main/initzm.sh
echo "You can now connect to Zoneminder at $(ip -oneline -family inet address show | grep "${IPv4bare}/" | awk '{print $4}' | awk 'END {print}' | sed 's/.\{3\}$//'):8080/zm"
echo "To start it you can run this command at the / dir : bash initzm.sh"