-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·84 lines (68 loc) · 2.53 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
#!/bin/bash
# Default Python version
PYTHON_VERSION="python3"
# Parse command line arguments
while getopts "p:" opt; do
case $opt in
p) PYTHON_VERSION="$OPTARG"
;;
*) echo "Usage: $0 [-p python_version]"
exit 1
;;
esac
done
echo "Using Python version: $PYTHON_VERSION"
# Check if virtualenv is installed
if ! command -v virtualenv &> /dev/null
then
echo "virtualenv could not be found. Installing..."
pip install virtualenv
fi
# Delete virtual environment if it already exists
if [ -d /var/lib/philologic5 ]; then
echo "Deleting existing PhiloLogic5 installation..."
sudo rm -rf /var/lib/philologic5
fi
# Create virtual environment
sudo mkdir -p /var/lib/philologic5
sudo chown -R $USER:$USER /var/lib/philologic5
virtualenv -p $PYTHON_VERSION /var/lib/philologic5/philologic_env
# Activate virtual environment
source /var/lib/philologic5/philologic_env/bin/activate
# Install required packages
python -m ensurepip --upgrade
python -m pip install build
echo -e "\n## INSTALLING PYTHON LIBRARY ##"
cd python
rm -rf dist/
python3 -m build --sdist
python -m pip install dist/*gz
# Deactivate virtual environment
deactivate
cd ..
# Install philoload5 script
echo -e '#!/bin/bash\nsource /var/lib/philologic5/philologic_env/bin/activate\npython3 -m philologic.loadtime "$@"\ndeactivate' > philoload5 && sudo mv philoload5 /usr/local/bin/
sudo chmod 775 /usr/local/bin/philoload5
sudo mkdir -p /etc/philologic/
sudo mkdir -p /var/lib/philologic5/web_app/
sudo rm -rf /var/lib/philologic5/web_app/*
if [ -d www/app/node_modules ]; then
sudo rm -rf www/app/node_modules
fi
sudo cp -R www/* /var/lib/philologic5/web_app/
sudo cp www/.htaccess /var/lib/philologic5/web_app/
if [ ! -f /etc/philologic/philologic5.cfg ]; then
db_url="# Set the filesystem path to the root web directory for your PhiloLogic install.
database_root = None
# /var/www/html/philologic/ is conventional for linux,
# /Library/WebServer/Documents/philologic for Mac OS.\n"
sudo echo -e "$db_url" | sed "s/^ *//g" | sudo tee /etc/philologic/philologic5.cfg > /dev/null
url_root="# Set the URL path to the same root directory for your philologic install.
url_root = None
# http://localhost/philologic/ is appropriate if you don't have a DNS hostname.\n"
sudo echo -e "$url_root" | sed "s/^ *//g" | sudo tee -a /etc/philologic/philologic5.cfg > /dev/null
else
echo -e "\n## WARNING ##"
echo "/etc/philologic/philologic5.cfg already exists"
echo "Please delete and rerun the install script to avoid incompatibilities\n"
fi