-
Notifications
You must be signed in to change notification settings - Fork 0
/
LaunchBarrier.sh
95 lines (86 loc) · 2.47 KB
/
LaunchBarrier.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
#!/bin/bash
while true; do
read -p "Do you want to launch Barrier at startup? (Y,N) " yn
case $yn in
[Yy]* ) yn=Y; break;;
[Nn]* ) yn=N; break;;
* ) echo "Please answer yes (Y) or no (N) : ";;
esac
done
## Answer is Yes - Barrier Configuration
if [ $yn = Y ]; then
echo "Yes"
while true; do
read -p "Do you want to launch Barrier as Server or Client? (S = Server | C = Client) : " sc
case $sc in
[Ss]* ) sc=S; break;;
[Cc]* ) sc=C; break;;
* ) echo"";echo "Please answer Server (S) or Client (C). CTRL C to Cancel ";;
esac
done
## Setting-up Barrier
## Setting-up server
if [ $sc = S ]; then
echo -n "Input the Barrier server name: "
read -r bsname
sudo echo \
"[Unit]
Description=Barrier Server mouse/keyboard share
Requires=display-manager.service
After=display-manager.service
StartLimitIntervalSec=0
[Service]
Type=forking
ExecStart=nice --5 /usr/bin/barriers --no-tray --no-restart --name $bsname --enable-crypto -c /tmp/Barrier.hlsSpA --address:24800
Restart=always
RestartSec=10
User=$USER
CPUSchedulingPriority=70
[Install]
WantedBy=multi-user.target" \
> /etc/systemd/system/barriers.service
echo ""
echo "Barrier: Launching server"
sudo systemctl daemon-reload
sudo systemctl start barrierc.service
sudo systemctl enable barrierc.service
echo "Done"
## Setting-up client
elif [ $sc = C ]; then
echo -n "Input the Barrier server computer name or the IP address (E.g Linux-Computer1.local or 192.168.1.1) : "
read -r bsname
echo -n "Input the Barrier client computer name : "
read -r bcname
sudo echo \
"[Unit]
Description=Barrier Client mouse/keyboard share
Requires=display-manager.service
After=display-manager.service
StartLimitIntervalSec=0
[Service]
Type=forking
ExecStart=nice --5 /usr/bin/barrierc --no-tray --no-restart --name $bcname --enable-crypto $bsname:24800
Restart=always
RestartSec=10
User=$USER
CPUSchedulingPriority=70
[Install]
WantedBy=multi-user.target" \
> /etc/systemd/system/barrierc.service
echo ""
echo "Barrier: Launching client"
sudo systemctl daemon-reload
sudo systemctl start barrierc.service
sudo systemctl enable barrierc.service
echo "Done"
else
echo "Please answer server (S) or client (C). CTRL C to Cancel : "
fi
## Answer is No - End
elif [ $yn = N ]; then
echo ""
echo "Installation of Barrier Deamon aborted"
echo ""
else
echo "Please answer yes (Y) or no (N). CTRL C to Cancel : "
fi