-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinstall.sh
executable file
·61 lines (50 loc) · 1.19 KB
/
install.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
#!/bin/bash
# Check for Rust Function
check_rust() {
echo '🦀 Checking for Rust'
if ! command -v rustc &> /dev/null; then
echo '⛔ Could not locate Rust Compiler ⛔'
echo 'Try running:'
echo 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh'
exit
else
echo '✅ Its Rusty!'
fi
}
build_app() {
if [ -f "uni-sync" ]; then
rm uni-sync
fi
echo '⚒️ Building Uni-Sync'
cargo build --release
if [ ! -f "target/release/uni-sync" ]; then
echo '⛔ Build Failed ⛔'
exit
fi
mv target/release/uni-sync .
rm -rf ./target
}
install_app() {
cat > 'uni-sync.service' << SERVICE
[Unit]
Description=Uni-Sync service
[Service]
ExecStart=/usr/sbin/uni-sync
[Install]
WantedBy=multi-user.target
SERVICE
sudo mv -f uni-sync.service /etc/systemd/system
sudo mv -f uni-sync /usr/sbin
sudo cp -n uni-sync.json /usr/sbin
sudo chown $USER /usr/sbin/uni-sync.json
sudo systemctl enable uni-sync
sudo systemctl restart uni-sync
}
check_rust
build_app
read -p "Would you like to install as Service? [N/y]: " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
install_app
fi