-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
installer.sh
75 lines (62 loc) · 2.08 KB
/
installer.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
#!/bin/bash
#
# Copyright © 2022 Anil Chauhan <https://github.com/meanii>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
## Installing sync.ssh from the source
echo "Installing sync.ssh"
go install .
## Checking, if golang weather installed or not
if ! command -v go &> /dev/null
then
echo "golang could not be found!"
exit
fi
## Checking got GOPATH ENV
if [[ -z "${GOPATH}" ]];
then
echo "GOPATH ENV couldn't found!"
exit
fi
## Preparing daemon file
echo "setting up daemon services"
SYNCSSH_PATH=/usr/local/bin/sync.ssh
SEVICE_FILE_BIN=service/sync_bin.service
SEVICE_FILE=service/sync.service
TIMER_FILE=service/sync.timer
SYSTEMD_PATH=/lib/systemd/system/
USERNAME=$(whoami)
echo "adding daemon for $USERNAME user!"
## Coping bin to cp /usr/local/bin/
sudo cp "$(which sync.ssh)" $SYNCSSH_PATH
sudo cat $SEVICE_FILE_BIN | sed "s|SYNCSSH_PATH|$SYNCSSH_PATH|g; s|USERNAME|$USERNAME|g;" > $SEVICE_FILE
## Coping Prepared Daemon file to the /lib/systemc/system
echo "copying demon service files"
sudo cp $SEVICE_FILE $SYSTEMD_PATH
sudo cp $TIMER_FILE $SYSTEMD_PATH
## Reloading, Enabling and Starting the daemon services
sudo systemctl daemon-reload
sudo systemctl enable sync
sudo systemctl enable sync.timer
sudo systemctl start sync
sudo systemctl start sync.timer
## Checking, if sync.ssh is installed properly or not
if ! command -v sync.ssh &> /dev/null
then
echo "something went wrong while installing sync.ssh!"
exit
else
echo "sync.ssh installation has been done!"
echo "try sync.ssh --help"
fi