forked from HariSekhon/DevOps-Python-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjython_install.sh
executable file
·58 lines (53 loc) · 1.92 KB
/
jython_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
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2016-08-01 10:17:55 +0100 (Mon, 01 Aug 2016)
#
# https://github.com/harisekhon/devops-python-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
set -eu
[ -n "${DEBUG:-}" ] && set -x
srcdir="$(cd "$(dirname "$0")" && pwd)"
JYTHON_VERSION="${1:-2.7.0}"
JYTHON_INSTALL_DIR="${2:-/opt/jython-$JYTHON_VERSION}"
# not set in busybox
#[ $EUID -eq 0 ] && sudo="" || sudo=sudo
[ $(whoami) = "root" ] && sudo="" || sudo=sudo
# installer will tell us if dir isn't empty
#if ! [ -e "$JYTHON_INSTALL_DIR" ]; then
$sudo mkdir -p "$JYTHON_INSTALL_DIR"
wget -cO jython-installer.jar "http://search.maven.org/remotecontent?filepath=org/python/jython-installer/$JYTHON_VERSION/jython-installer-$JYTHON_VERSION.jar"
#$sudo expect "$srcdir/jython_autoinstall.exp"
#
# 'core' = too minimal to be useful to my real world programs, install results in:
# import socket
# ...
# ImportError: No module named encodings
#
#$sudo java -jar jython-installer.jar --silent --include mod --include ensurepip --directory "$JYTHON_INSTALL_DIR"
$sudo java -jar jython-installer.jar -s -t standard -d "$JYTHON_INSTALL_DIR"
$sudo rm -fr "$JYTHON_INSTALL_DIR"/{Docs,Demo,tests}
$sudo ln -sf "$JYTHON_INSTALL_DIR" /opt/jython
rm -f jython-installer.jar
echo
echo "Jython Install done"
#else
# echo "$JYTHON_INSTALL_DIR already exists - doing nothing"
#fi
if ! [ -e /etc/profile.d/jython.sh ]; then
echo "Adding /etc/profile.d/jython.sh"
# shell execution tracing comes out in the file otherwise
set +x
cat >> /etc/profile.d/jython.sh <<EOF
export JYTHON_HOME=/opt/jython
export PATH=\$PATH:\$JYTHON_HOME/bin
EOF
fi
echo "DONE"