-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·93 lines (72 loc) · 1.8 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
#!/bin/bash
GIT_OWNER="https://github.com/happysources"
GIT_REPO="server4-api-py"
TMP_DIR="/tmp/${GIT_REPO}"
INST_DIR="/usr/local/lib/python3/dist-packages/"
echo "start ... "
echo
# redhat
if [ -f "/etc/redhat-release" ]; then
DISTNAME="redhat";
DISTFILE="/etc/redhat-release";
# centos
elif [ -f "/etc/centos-release" ]; then
DISTNAME="centos";
DISTFILE="/etc/redhat-release";
# fedora
elif [ -f "/etc/fedora-release" ]; then
DISTNAME="fedora";
DISTFILE="/etc/redhat-release";
# debian
elif [ -f "/etc/debian_version" ]; then
DISTNAME="debian";
DISTFILE="/etc/debian_version";
# other
elif [ -f "/etc/os-release" ]; then
DISTNAME=`cat /etc/os-release | grep -v "_ID=" | grep "ID=" | cut -d"=" -f2`;
DISTFILE="/etc/os-release";
else
echo "unsupported linux distribution. exit";
exit;
fi
echo "distribution ... "
echo "* name: $DISTNAME ";
echo -n "* version: "
cat $DISTFILE
# install apt for rhel os
if [ "$DISTNAME" = "redhat" ] || [ "$DISTNAME" = "centos" ] || [ "$DISTNAME" = "fedora" ]; then
echo "* $DISTNAME install apt"
yum install apt;
fi;
# test if sudo install
if [ ! -f "/usr/bin/sudo" ]; then
echo "* sudo install"
apt install sudo
fi;
# test if git install
if [ ! -f "/usr/bin/git" ]; then
echo "* sudo git"
sudo apt install git
fi;
echo
cd /tmp/
echo "${GIT_REPO} ... "
echo -n "* clean ... "
sudo rm -rf $TMP_DIR
echo "done."
echo -n "* git clone ... "
git clone -q ${GIT_OWNER}/${GIT_REPO}.git
echo "done."
echo -n "* create dir ... "
sudo mkdir -p $INST_DIR
echo "done."
echo -n "* script install ... "
for pyfile in `find ${TMP_DIR} | grep "\.py" | grep -v '__pycache__' | grep -v "\.pyc" | grep -v "pylintrc" | grep -v "__init__" | grep -v "test/"`; do
sudo cp -v $pyfile $INST_DIR/.;
done;
echo "done."
echo -n "* clean ... "
sudo rm -rf $TMP_DIR
echo "done."
echo
echo "end."