-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall.sh
executable file
·169 lines (130 loc) · 4.56 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
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
#!/bin/bash
USER=$(stat -c '%U' .)
PUSER=mcloud
PPASS=mcloud
PHOME=/home/mcloud
pushfolder="src/core/push"
pullfolder="src/core/pull"
flushfolder="src/core/flush"
# Usage info
show_help() {
cat << EOF
Usage: ${0##*/} [-hvd] [-t TYPE]
Do stuff to install MCloud in different ways
-h display this help and exit
-t TYPE choose the type you wanna install
-v verbose mode. Can be used multiple times for increased
verbosity.
-d dev mode. Only if you want to develop and test the system
TYPE -t OPTIONS:
client:
**NEEDS ROOT MODE: sudo ./install.sh client**
install default setup for client
this side of the system if th eclient, you need a provider attending to this client"
in order to get working properly
this side is supposed to have bad connection limited by local timetable
provider:
**NEEDS ROOT MODE: sudo ./install.sh provider**
install default setup for provider
you need to have a stable server with a good connection/internet access
EOF
}
# Initialize our own variables:
output_file=""
verbose=0
DEV=0
OPTIND=1
# Resetting OPTIND is necessary if getopts was used previously in the script.
# It is a good idea to make OPTIND local if you process options in a function.
while getopts hvdt: opt; do
case $opt in
h)
show_help
exit 0
;;
v) verbose=$((verbose+1))
;;
d) DEV=$((DEV+1))
;;
t) arg_type=$OPTARG
;;
*)
show_help >&2
exit 1
;;
esac
done
shift "$((OPTIND-1))" # Shift off the options and optional --.
# Everything that's left in "$@" is a non-option. In our case, a FILE to process.
#printf 'verbose=<%d>\ntype=<%s>\nLeftovers:\n' "$vierbose" "$arg_type"
#printf '<%s>\n' "$@"
echo welcome
echo $arg_type
case "$arg_type" in
"provider")
echo "installing provider setup..."
getent passwd $PUSER > /dev/null
if [ $? -eq 0 ]; then
echo "user mcloud exists"
else
useradd -m -d $PHOME -s /bin/bash -c "user 4 mcloud service" -U $PUSER
echo $PUSER:$PPASS | chpasswd
echo "user mcloud created"
fi
if ps ax | grep -v grep | grep "proftpd" > /dev/null; then
echo "found proftpd running :)"
echo "we are moving your old /etc/proftpd/proftpd.conf -> proftpd.conf.bak"
mv /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf.bak
cp proftpd.conf /etc/proftpd/proftpd.conf
service proftpd restart
else
echo "proftpd is not running"
echo "In order to run provider client you need proftpd (or similar) running"
echo "try sudo service proftpd start if u already have installed proftpd"
echo "if u wanna install: sudo apt-get install proftpd (debian based)"
fi
mkdir $PHOME/MCloud
if [ "$DEV" -gt 0 ]; then
echo "creating dev links!"
cp -as "$(pwd)/inet_side" $PHOME/MCloud/inet_side
else
cp -r inet_side $PHOME/MCloud
fi
mkdir $PHOME/MCloud/inet_side/received
mkdir $PHOME/MCloud/inet_side/out
mkdir $PHOME/MCloud/inet_side/mcloud_iside/youtube
mkdir $PHOME/MCloud/inet_side/mcloud_iside/vademecum/resultsMedicamentos
mkdir $PHOME/MCloud/inet_side/mcloud_iside/vademecum/resultsTar
chown -R $PUSER:$PUSER $PHOME/MCloud
(cd $PHOME/MCloud/inet_side && pip install -r requirements.txt)
;;
"client")
echo "creating folders..."
if [ ! -d "$pullfolder" ]; then
mkdir $pullfolder
fi
if [ ! -d "$pushfolder" ]; then
mkdir $pushfolder
fi
if [ ! -d "$flushfolder" ]; then
mkdir $flushfolder
fi
chown -R $USER:$USER .
if ps ax | grep -v grep | grep "mongodb" > /dev/null; then
echo "found mongodb running :)"
else
echo "mongodb is not running"
echo "In order to run the client you need mongodb (or similar) running"
echo "try:"
echo "$ sudo nohup mongod &"
echo "this will run mongod from the background"
echo "if u wanna install: sudo apt-get install mongodb (debian based)"
fi
npm install -g create-react-app
npm install -g concurrently
echo
echo
npm i
chown -R $USER:$USER .
;;
esac