-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
285 lines (277 loc) · 8.75 KB
/
setup.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
#title :setup.sh
#description :Installation of the nesseary tools
#author :Stefan Baumgartner
#date :15.06.2018
#version :1.00
#usage :bash setup.sh
#notes :Please modify only if you know what you do
########################################################################
########################################################################
# Developed by Store-Host #
# Version 0.1 #
# Web: https://www.store-host.com #
# Mocis 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. #
########################################################################
########################################################################
# Variables #
########################################################################
# Test änderung
scriptname="mocis"
scriptnamezipped="mocis.zip"
start_path="/usr/local/bin"
path="/usr/local/share/mocis"
installedname="mocis"
version="0.2.00"
giturl="https://github.com/StoreHost/Mocis.SH.git"
updateurl=$giturl
gitname="Mocis.SH"
_gitclone() {
cd /tmp/
git clone --quiet https://github.com/StoreHost/Mocis.SH.git
return 0
}
########################################################################
# Spinner #
########################################################################
spin() {
local -a marks=( '/' '-' '\' '|' )
while [[ 1 ]]; do
printf '%s\r' "${marks[i++ % ${#marks[@]}]}"
sleep 1
done
}
########################################################################
function _legal() {
cat <<"EOF"
Mocis 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.
EOF
}
########################################################################
# Powered by #
########################################################################
function _printPoweredBy()
{
cat <<"EOF"
Powered By:
__ __ _ _____ _ _
| \/ | (_) / ____| | | |
| \ / | ___ ___ _ ___ | (___ | |__| |
| |\/| |/ _ \ / __| / __| \___ \| __ |
| | | | (_) | (__| \__ \_ ____) | | | |
|_| |_|\___/ \___|_|___(_)_____/|_| |_|
>> Web: https://mocis.sh
>> Store: https://www.store-host.com
################################################################
EOF
}
########################################################################
# Check OS #
########################################################################
if [ -d "/etc/apt" ]; then
pmgr=apt-get
fi
if [ -d "/etc/yum" ]; then
pmgr=yum
exit 0
fi
########################################################################
# Binary Installer #
########################################################################
function _install_binarys {
_install() {
echo -ne "Install git: " && $pmgr -y install git >/dev/null &&
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo " [Ok]"
else
echo " [Failed]"
exit 1
fi
echo -ne "Install python: " && $pmgr -y install python >/dev/null &&
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo " [Ok]"
else
echo " Failed]"
exit 1
fi
}
echo "We have to install some packages\n You want to allow it?"
select yn in "Yes" "No"; do
case $yn in
Yes ) _install; break;;
No ) exit;;
esac
done
# $pmgr -y install git wget zip python >/dev/null && \
# $pmgr -y install python-pip -y >/dev/null && \
# pip install wget >/dev/null && \
#RESULT=$?
#if [ $RESULT -eq 0 ]; then
# echo " [Ok]"
#else
# echo " [failed]"
#fi
}
########################################################################
# Updating #
########################################################################
_update(){
git clone -s $giturl
mv $gitname $scriptname
if [ -d $path ]; then
echo "Directory is existing..."
rm -rf $path
rm -rf $start_path
mkdir -p $path
mkdir -p $start_path
mv mocis/* $path/
rm -rf $scriptname
mv $path/lib/mocis.sh $start_path/mocis
chmod -+x $start_path/mocis
python $path/lib/ini.py
cd ~
clear
echo "Installation Done"
echo ""
echo "You can now use Mocis."
echo "Type $scriptname -s or $scriptname -h for help"
else
echo "could not update... somethint went wrong"
exit 1
fi
}
########################################################################
# Local Installation #
########################################################################
function _installlocal() {
_legal
echo ">Accept< >Exit<"
read legal
if [[ $legal =~ ^([aA][cC][cC]|[eE]|[pP]|[tT])+$ ]]; then
if [ -d $path ]; then
echo "Mocis dound... Trying to update $scriptname"
fi
_install_binarys
git clone -s $giturl
mv $gitname $scriptname
if [ -d $path ]; then
echo "Directory is existing..."
rm -rf $path
rm -rf $start_path
mkdir -p $path
mkdir -p $start_path
mv mocis/* $path/
rm -rf $scriptname
mv $path/lib/mocis.sh $start_path/mocis
chmod -+x $start_path/mocis
python $path/lib/ini.py
cd ~
clear
echo "Installation Done"
echo ""
echo "You can now use Mocis."
echo "Type $scriptname -s or $scriptname -h for help"
else
echo "Directory is not existing"
mkdir -p $path
mkdir -p $start_path
mv mocis/* $path/
rm -rf $scriptname
mv $path/lib/mocis.sh $start_path/mocis
chmod -+x $start_path/mocis
python $path/lib/ini.py
cd ~
clear
echo "Installation Done"
echo ""
echo "You can now use Mocis."
echo "Type $scriptname -s or $scriptname -h for help"
fi
fi
}
########################################################################
# HELP Text #
########################################################################
function _helptxt() {
echo "hello and welcome with the help of Mocis."
echo "You are welcome to add the lower commands as an argument to the script,"
echo "for example, for single functions or direct start "
}
########################################################################
# The command line help #
########################################################################
_display_help() {
echo
echo
echo
echo "Usage: $0 " >&2
_printPoweredBy
echo
_helptxt
echo
echo " -h --help shows this help"
echo " -i, --install install local to the system"
echo " -u --update Update to the latest version"
echo " -v, --version Shows the actual version"
echo
# echo some stuff here for the -a or --add-options
exit 1
}
########################################################################
# Check if parameters options #
# are given on the commandline #
########################################################################
while :
do
case "$1" in
-r | --resolution)
if [ $# -ne 0 ]; then
resolution="$2" # You may want to check validity of $2
fi
shift 2
;;
-h | --help)
_display_help # Call your function
exit 0
;;
-i | --install)
_installlocal
exit 0
;;
-u | --update)
echo "getting the newest version..."
_update
exit 0
;;
-v | --version)
echo "Version $version is installed"
exit 0
;;
--) # End of all options
shift
break
;;
-*)
echo "Error: Unknown option: $1" >&2
## or call function display_help
exit 1
;;
*) # No more options
break
;;
esac
done
########################################################################
# Core !do not touch! #
########################################################################
clear
_installlocal