-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathinstall.sh
executable file
·140 lines (118 loc) · 3.83 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
#!/usr/bin/env bash
INSTALL_PYTHON3=0
INSTALL_VIRTUALENV=0
INSTALL_PIP=0
INSTALLDIR=/opt/cycle/gridengine
VENV=$INSTALLDIR/venv
OS=$(awk -F= '/^NAME/{print $2}' /etc/os-release | awk '{print tolower($0)}')
if [ "$OS" == '"ubuntu"' ]; then
INSTALL_CMD=apt-get
# ubuntu 18 does not include pip by default
INSTALL_PIP=1
else
INSTALL_CMD=yum
fi
while (( "$#" )); do
case "$1" in
--install-python3)
INSTALL_PYTHON3=1
INSTALL_PIP=1
INSTALL_VIRTUALENV=1
shift
;;
--install-venv)
INSTALL_VIRTUALENV=1
shift
;;
--venv)
VENV=$2
shift 2
;;
--help)
echo ./install.sh [--install-python3] [--install-venv] [--venv $VENV]
exit 1
;;
-*|--*=)
echo "Unknown option $1" >&2
exit 1
;;
*)
echo "Unknown option $1" >&2
exit 1
;;
esac
done
echo INSTALL_PYTHON3=$INSTALL_PYTHON3
echo INSTALL_VIRTUALENV=$INSTALL_VIRTUALENV
echo VENV=$VENV
# DEPRECATED: For versions < 8.7.0: Remove any jetpack references from the path.
echo $PATH | sed -E -e 's/\/opt\/cycle\/jetpack\/[^:]*://g'
# Require python3.8 - 3.12. Unfortunately the default python3 is 3.6 on alma
PYTHON_EXE=$(which python3.8 || which python3.9 || which python3.10 || which python3.11 || which python3.12 || which python3)
# if it does not exist, install it if the user requested it and then set PYTHON_EXE.
if [ $? != 0 ]; then
if [ $INSTALL_PYTHON3 == 1 ]; then
$INSTALL_CMD install -y python3 || exit 1
PYTHON_EXE=$(which python3)
else
echo Please install python3.8 or newer >&2;
exit 1
fi
fi
# Make sure that the python version is supported.
PYTHON_VERSION=$($PYTHON_EXE --version | awk '{print $2}')
$PYTHON_EXE -c 'import sys; sys.exit(0 if sys.version_info >= (3,8) else 1)'
if [ $? != 0 ]; then
echo "Python version $PYTHON_VERSION is not supported. Please install python3.8 or newer" >&2
exit 1
fi
$PYTHON_EXE -m pip 2>&1 1> /dev/null
if [ $? != 0 ]; then
if [ $INSTALL_PIP == 1 ]; then
$INSTALL_CMD install -y ${PYTHON_VERSION}-pip || exit 1
else
echo Please install ${PYTHON_VERSION}-pip >&2;
exit 1
fi
fi
$PYTHON_EXE -m virtualenv --version 2>&1 > /dev/null
if [ $? != 0 ]; then
if [ $INSTALL_VIRTUALENV ]; then
$PYTHON_EXE -m pip install virtualenv || exit 1
else
echo Please install virtualenv for $PYTHON_EXE >&2
exit 1
fi
fi
$PYTHON_EXE -m virtualenv $VENV
source $VENV/bin/activate
# not sure why but pip gets confused installing frozendict locally
# if you don't install it first. It has no dependencies so this is safe.
pip install --force-reinstall packages/*
cat > $VENV/bin/azge <<EOF
#!$VENV/bin/python
import warnings
warnings.filterwarnings("ignore", message="Please use driver.new_singleton_lock")
from gridengine.cli import main
main()
EOF
chmod +x $VENV/bin/azge
azge -h 2>&1 > /dev/null || exit 1
ln -sf $VENV/bin/azge /usr/local/bin/
if [ ! -e /root/bin ]; then
mkdir /root/bin
fi
ln -sf $VENV/bin/azge /root/bin/
echo 'azge' installed. A symbolic link was made to /usr/local/bin/azge and /root/bin
cp logging.conf $INSTALLDIR/
crontab -l > /tmp/current_crontab
grep -q 'Created by cyclecloud-gridengine install.sh' /tmp/current_crontab
if [ $? != 0 ]; then
echo \# Created by cyclecloud-gridengine install.sh >> /tmp/current_crontab
echo '* * * * * . /etc/profile.d/sgesettings.sh && /usr/local/bin/azge autoscale -c /opt/cycle/gridengine/autoscale.json' >> /tmp/current_crontab
crontab /tmp/current_crontab
fi
rm -f /tmp/current_crontab
crontab -l | grep -q 'Created by cyclecloud-gridengine install.sh' && exit 0
echo "Could not install cron job for autoscale!" >&2
exit 1