This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
install
145 lines (110 loc) · 4.87 KB
/
install
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
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
source _common.sh # Loads the generic functions usually used in the script
source /usr/share/yunohost/helpers # Source app helpers
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH_URL
admin=$YNH_APP_ARG_ADMIN
language=$YNH_APP_ARG_LANGUAGE
is_public=$YNH_APP_ARG_IS_PUBLIC
github_key=$YNH_APP_ARG_GITHUB_KEY
github_secret=$YNH_APP_ARG_GITHUB_SECRET
github_scope=$YNH_APP_ARG_GITHUB_SCOPE
bitbucket_key=$YNH_APP_ARG_BITBUCKET_KEY
bitbucket_secret=$YNH_APP_ARG_BITBUCKET_SECRET
twitter_key=$YNH_APP_ARG_TWITTER_KEY
twitter_secret=$YNH_APP_ARG_TWITTER_SECRET
openstreetmap_key=$YNH_APP_ARG_OPENSTREETMAP_KEY
openstreetmap_secret=$YNH_APP_ARG_OPENSTREETMAP_SECRET
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
#=================================================
ynh_user_exists "$admin" || ynh_die "user $admin does not exist"
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path
ynh_webpath_register $app $domain $path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app language $language
ynh_app_setting_set $app is_public $is_public
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# Install dependency to convert tracks to a readable format for the browser
ynh_package_update
ynh_package_install postgresql postgresql-server-dev-9.6 postgis postgresql-9.6-postgis-2.3 python-pip git python-virtualenv virtualenvwrapper python3-dev python3-setuptools libtiff5-dev libjpeg62-turbo-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk python3.5-dev python-dev python-imaging postgresql-9.6-postgis-scripts
# Prepare Umap to be installed
sudo mkdir -p /opt/$app
sudo useradd -N $app -d /opt/$app/
# Create role and database with a password
ynh_psql_setup_db $app $app
# Activate PostGIS extension
ynh_psql_create_extension $app postgis
sudo mkdir -p $final_path/venv
sudo chown -R umap: $final_path
# Installation de "umap"
sudo su $app -c "virtualenv -p /usr/bin/python3 --distribute --no-site-packages ${final_path}/venv"
sudo bash -c "source ${final_path}/venv/bin/activate && pip3 install umap-project && pip3 install uwsgi"
localfile="${final_path}/venv/local.py"
sudo bash -c "source ${final_path}/venv/bin/activate && wget https://raw.githubusercontent.com/umap-project/umap/master/umap/settings/local.py.sample -O ${localfile}"
# Replace variables configuration
secret=$(ynh_string_random 24)
language="$(echo $language | head -c 2)"
ynh_replace_config_umap
# Create STATIC & MEDIA dir
sudo mkdir "${final_path}/static"
sudo mkdir "${final_path}/data"
# export env
# sudo bash -c "source ${final_path}/venv/bin/activate && env = UMAP_SETTINGS=${final_path}/venv/local.py"
# Install umap
sudo bash -c "source ${final_path}/venv/bin/activate && export UMAP_SETTINGS=${localfile} && umap migrate && echo yes | umap collectstatic && umap storagei18n"
# Create superuser
sudo bash -c "source ${final_path}/venv/bin/activate && export UMAP_SETTINGS=${localfile} && umap createsuperuser --username ${admin} --email ${admin}@${domain} --noinput"
# Create datalayer directory
sudo mkdir /opt/umap/data/datalayer
sudo chown -R umap:users /opt/umap/data/datalayer
# Copy Files
sudo cp ../conf/uwsgi_params $final_path/uwsgi_params
sudo cp ../conf/uwsgi.ini $final_path/uwsgi.ini
sudo sed -i "s@__APP__@$app@g" $final_path/uwsgi.ini
# Config service
sudo mkdir -p /etc/uwsgi/apps-enabled/
sudo ln -s $final_path/uwsgi.ini /etc/uwsgi/apps-enabled/umap.uwsgi.ini
# Start service
sudo systemctl enable uwsgi
sudo systemctl restart uwsgi
# Add umap.uwsgi as a service
sudo yunohost service add umap.uwsgi
# Modify Nginx configuration file and copy it to Nginx conf directory
ynh_nginx_config
# Set ssowat config
if [ $is_public -eq 0 ]
then
ynh_app_setting_delete $app skipped_uris # Delete public access
fi
if [ $is_public -eq 1 ]
then
ynh_app_setting_set $app skipped_uris "/" # Make app public if necessary
fi
# Reload nginx
sudo systemctl reload nginx