-
Notifications
You must be signed in to change notification settings - Fork 0
/
Install.sh
executable file
·124 lines (97 loc) · 2.71 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
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
#!/bin/bash
od="$HOME/.odrive-agent/bin"
if [[ $# -gt 0 ]]; then
## UNISTALL
if [[ $1 == "Un" ]]; then
echo "Uninstalling ..."
if [[ $2 == "A" ]]; then
rm -Rf $HOME/.odrive-agent
fi
rm -Rf $HOME/.Odrish
rm -f $HOME/.local/bin/odr
echo "Uninstalled"
exit
## INSTALL
elif [[ $1 == "In" ]]; then
# Odrive install
mkdir --parents $od
curl -L "https://dl.odrive.com/odriveagent-lnx-64" | tar -xvzf- -C "$od/"
if [[ $2 == "P" ]]; then
curl -L "https://dl.odrive.com/odrive-py" -o "$od/odrive.py"
elif [[ $2 == "B" ]]; then
curl -L "https://dl.odrive.com/odrivecli-lnx-64" | tar -xvzf- -C "$od/"
fi
# Odrish_log installer
if [ ! -d "$HOME/.Odrish" ]; then
mkdir $HOME/.Odrish
echo "Installing..." > $HOME/.Odrish/Log
date > $HOME/.Odrish/Log
fi
# Odrish_bin installer
if [ ! -d "$HOME/.local/bin" ]; then
mkdir $HOME/.local/bin
echo created ${HOME}.local/bin >> $HOME/.Odrish/Log
fi
cp -f odr $HOME/.local/bin/
# Make clean config in install
if [ ! -f "$HOME/.Odrish/config" ]; then
echo "# Odrish configs" > $HOME/.Odrish/config
fi
# Make target file
touch $HOME/.Odrish/target
# Selecting agent
sed -i '/^alias odrive=.*$/d' $HOME/.Odrish/config
if [[ $2 == "B" ]]; then
odrive="$HOME/.odrive-agent/bin/odrive"
elif [[ $2 == "P" ]]; then
odrive="python3 $HOME/.odrive-agent/bin/odrive.py"
fi
echo "alias odrive='$odrive'" >> $HOME/.Odrish/config
sed -i '/^$/d' $HOME/.Odrish/config
exit
## UPGRADE
elif [[ $1 == "Up" ]]; then
# Log
date >> $HOME/.Odrish/Log
echo "updating: $1 $2" >> $HOME/.Odrish/Log
# Update odrish
cp -f odr $HOME/.local/bin/
if [[ -z "$2" ]]; then
exit
fi
# Odrive update
curl -L "https://dl.odrive.com/odriveagent-lnx-64" | tar -xvzf- -C "$od/"
if [[ $2 == "P" ]]; then
curl -L "https://dl.odrive.com/odrive-py" -o "$od/odrive.py"
elif [[ $2 == "B" ]]; then
curl -L "https://dl.odrive.com/odrivecli-lnx-64" | tar -xvzf- -C "$od/"
fi
# Selecting agent
sed -i '/^alias odrive=.*$/d' $HOME/.Odrish/config
if [[ $2 == "B" ]]; then
odrive="$HOME/.odrive-agent/bin/odrive"
elif [[ $2 == "P" ]]; then
odrive="python3 $HOME/.odrive-agent/bin/odrive.py"
fi
echo "alias odrive='$odrive'" >> $HOME/.Odrish/config
sed -i '/^$/d' $HOME/.Odrish/config
exit
fi
fi
## Error CASE
echo "./Install Up [ | P | B ]"
echo ""
echo " = Only Odrish"
echo "P = Update and configure Python CLI"
echo "B = Update and configure Bash CLI"
echo ""
echo "Wrong Arguments. Use:"
echo "./Install Un [ | A ]"
echo ""
echo " = Only Odrish"
echo "A = All, including odrive agent"
echo ""
echo "./Install In [ P | B ]"
echo ""
echo "P = Use Python CLI"
echo "B = Use Bash CLI"