-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathservices.sh
163 lines (137 loc) · 3.96 KB
/
services.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env bash
set -eu
WIRINGOP_REPO=https://github.com/orangepi-xunlong/wiringOP.git
USTREAMER_REPO=https://github.com/pikvm/ustreamer
KIAUH_REPO=https://github.com/th33xitus/kiauh.git
TELEGRAM_BOT_REPO=https://github.com/nlef/moonraker-telegram-bot
install_wiringop(){
cd ~
WOP_FOLDER=wiringOP
if [ ! -d "${WOP_FOLDER}" ] ; then
git clone ${WIRINGOP_REPO} ${WOP_FOLDER}
cd "${WOP_FOLDER}"
else
cd "${WOP_FOLDER}"
git pull ${WIRINGOP_REPO}
fi
sudo ./build clean
sudo ./build
}
install_deps(){
sudo apt update
sudo apt-get install --yes zlib1g-dev libjpeg-dev git build-essential libevent-dev libjpeg-dev libbsd-dev gpiod python3-numpy nmon ncdu
}
install_ustreamer(){
USTREAMER_USER=ustreamer
cd ~
USTR_FOLDER=ustreamer
if [ ! -d "${USTR_FOLDER}" ] ; then
git clone ${USTREAMER_REPO} ${USTR_FOLDER}
cd "${USTR_FOLDER}"
else
cd "${USTR_FOLDER}"
git pull ${USTREAMER_REPO}
fi
sudo make install
if [[ $(cat /etc/passwd | grep ${USTREAMER_USER} | wc -l) -eq 0 ]]; then
sudo useradd -r ${USTREAMER_USER}
fi
sudo usermod -a -G video ${USTREAMER_USER}
sudo /bin/sh -c "cat > /etc/systemd/system/ustreamer.service" <<EOF
[Unit]
Description=uStreamer service
After=network.target
[Service]
User=ustreamer
ExecStart=/usr/local/bin/ustreamer --process-name-prefix ustreamer-0 --log-level 0 --device=/dev/video0 --resolution=1920x1080 --format=MJPEG --encoder=HW --quality=100 --host=0.0.0.0 --port=8080 --workers=1
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
read -p "Do you want to enable ustreamer service? (y/N):" yn
while true; do
case "$yn" in
Y|y|Yes|yes)
sudo systemctl enable ustreamer.service
sudo systemctl start ustreamer.service
break;;
N|n|No|no|"") break;;
*) break;;
esac
done
}
install_vlc_streamer(){
VLCSTREAMER_USER=vlcstreamer
cd ~
sudo apt-get install --yes vlc
if [[ $(cat /etc/passwd | grep ${VLCSTREAMER_USER} | wc -l) -eq 0 ]]; then
sudo useradd -r ${VLCSTREAMER_USER}
fi
sudo usermod -a -G video ${VLCSTREAMER_USER}
sudo /bin/sh -c "cat > /etc/systemd/system/vlc-streamer.service" <<EOF
#Systemd service file for cvlc webcam stream
[Unit]
Description=Starts cvlc stream
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
User=vlcstreamer
ExecStart=cvlc -vvv v4l2:///dev/video0:chroma=h264:width=1920:height=1080:fps=30 --sout '#standard{access=http,mux=mp4frag,dst=:8080/stream.mp4}'
Restart=always
RestartSec=30
EOF
sudo systemctl daemon-reload
read -p "Do you want to enable vlc_stremer service? (y/N):" yn
while true; do
case "$yn" in
Y|y|Yes|yes)
sudo systemctl enable vlc-streamer.service
sudo systemctl start vlc-streamer.service
break;;
N|n|No|no|"") break;;
*) break;;
esac
done
}
download_kiauh(){
cd ~
KIAUH_FOLDER=kiauh
if [ ! -d "${KIAUH_FOLDER}" ] ; then
git clone ${KIAUH_REPO} ${KIAUH_FOLDER}
cd "${KIAUH_FOLDER}"
else
cd "${KIAUH_FOLDER}"
git pull ${KIAUH_REPO}
fi
read -p "Do you want return log path to /tmp? (y/N):" yn
while true; do
case "$yn" in
Y|y|Yes|yes)
echo "Return log path to /tmp"
find . -type f -print0 | xargs -0 sed -i 's|${HOME}/klipper_logs|/tmp|g'
break;;
N|n|No|no|"") break;;
*) break;;
esac
done
./kiauh.sh || :
}
install_telegram_bot(){
cd ~
TBOT_FOLDER=moonraker-telegram-bot
if [ ! -d "${TBOT_FOLDER}" ] ; then
git clone ${TELEGRAM_BOT_REPO} ${TBOT_FOLDER}
cd "${TBOT_FOLDER}"
else
cd "${TBOT_FOLDER}"
git pull ${TELEGRAM_BOT_REPO}
fi
./install.sh
}
install_wiringop
install_deps
install_ustreamer
install_vlc_streamer
download_kiauh
install_telegram_bot