102 lines
4.7 KiB
Bash
Executable File
102 lines
4.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
CONTAINER=$1
|
|
|
|
DOMAIN="logerais.com"
|
|
TIMEZONE="Europe/Paris"
|
|
|
|
if [ -z "$CONTAINER" ]; then echo "Missing parameter"; exit 1 ; fi
|
|
|
|
# Set container timezone
|
|
lxc file edit "$CONTAINER/etc/timezone" <<< "${TIMEZONE}"
|
|
|
|
# Install packages
|
|
lxc exec $CONTAINER -- apt update
|
|
|
|
lxc exec $CONTAINER -- apt install -y curl git make
|
|
|
|
lxc exec $CONTAINER -- apt install -y nginx
|
|
lxc exec $CONTAINER -- apt install -y postgresql
|
|
lxc exec $CONTAINER -- apt install -y redis-server
|
|
|
|
lxc exec $CONTAINER -- apt install -y php
|
|
lxc exec $CONTAINER -- apt install -y php-zip php-curl php-xml php-mbstring php-bcmath php-gd
|
|
lxc exec $CONTAINER -- apt install -y php-pgsql
|
|
|
|
lxc exec $CONTAINER -- phpenmod session
|
|
lxc exec $CONTAINER -- phpenmod ctype
|
|
lxc exec $CONTAINER -- phpenmod dom
|
|
lxc exec $CONTAINER -- phpenmod hash
|
|
lxc exec $CONTAINER -- phpenmod simplexml
|
|
lxc exec $CONTAINER -- phpenmod json
|
|
lxc exec $CONTAINER -- phpenmod gd
|
|
lxc exec $CONTAINER -- phpenmod mbstring
|
|
lxc exec $CONTAINER -- phpenmod xml
|
|
lxc exec $CONTAINER -- phpenmod tidy
|
|
lxc exec $CONTAINER -- phpenmod iconv
|
|
lxc exec $CONTAINER -- phpenmod curl
|
|
lxc exec $CONTAINER -- phpenmod gettext
|
|
lxc exec $CONTAINER -- phpenmod tokenizer
|
|
|
|
lxc exec $CONTAINER -- su --login postgres <<< "createuser wallabag"
|
|
lxc exec $CONTAINER -- su --login postgres <<< "createdb --owner=wallabag wallabag"
|
|
lxc exec $CONTAINER -- su --login postgres --shell /usr/bin/psql <<< "ALTER USER \"wallabag\" WITH PASSWORD 'wallabag';"
|
|
|
|
lxc exec $CONTAINER -- su --login root --shell /bin/bash <<< "cd /var/www && git clone https://github.com/wallabag/wallabag.git"
|
|
lxc exec $CONTAINER -- su --login root --shell /bin/bash <<< "cd /var/www/wallabag && curl -s https://getcomposer.org/installer | php"
|
|
lxc exec $CONTAINER -- su --login root --shell /bin/bash <<< "chown --recursive www-data:www-data /var/www/wallabag"
|
|
|
|
lxc exec $CONTAINER -- su --login www-data --shell /bin/bash <<< "cd /var/www/wallabag && cp app/config/parameters.yml.dist app/config/parameters.yml"
|
|
lxc exec $CONTAINER -- su --login www-data --shell /bin/bash <<< "cd /var/www/wallabag && sed -i -e '/database/ s/pdo_sqlite/pdo_pgsql/g' app/config/parameters.yml"
|
|
lxc exec $CONTAINER -- su --login www-data --shell /bin/bash <<< "cd /var/www/wallabag && sed -i -e '/database_name/ s/symfony/wallabag/g' app/config/parameters.yml"
|
|
lxc exec $CONTAINER -- su --login www-data --shell /bin/bash <<< "cd /var/www/wallabag && sed -i -e '/database_user/ s/root/wallabag/g' app/config/parameters.yml"
|
|
lxc exec $CONTAINER -- su --login www-data --shell /bin/bash <<< "cd /var/www/wallabag && sed -i -e '/database_password/ s/~/wallabag/g' app/config/parameters.yml"
|
|
lxc exec $CONTAINER -- su --login www-data --shell /bin/bash <<< "cd /var/www/wallabag && sed -i -e '/locale:/ s/en/fr/g' app/config/parameters.yml"
|
|
lxc exec $CONTAINER -- su --login www-data --shell /bin/bash <<< "cd /var/www/wallabag && sed -i -e '/fosuser_registration:/ s/true/false/g' app/config/parameters.yml"
|
|
|
|
lxc exec $CONTAINER -- su --login www-data --shell /bin/bash <<< "cd /var/www/wallabag && make install"
|
|
|
|
lxc file edit $CONTAINER/etc/nginx/sites-available/wallabag <<'EOF'
|
|
server {
|
|
|
|
server_name wallabag.logerais.com;
|
|
root /var/www/wallabag/web;
|
|
|
|
location / {
|
|
# try to serve file directly, fallback to app.php
|
|
try_files $uri /app.php$is_args$args;
|
|
}
|
|
location ~ ^/app\.php(/|$) {
|
|
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
|
|
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
|
include fastcgi_params;
|
|
# When you are using symlinks to link the document root to the
|
|
# current version of your application, you should pass the real
|
|
# application path instead of the path to the symlink to PHP
|
|
# FPM.
|
|
# Otherwise, PHP's OPcache may not properly detect changes to
|
|
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
|
|
# for more information).
|
|
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
|
fastcgi_param DOCUMENT_ROOT $realpath_root;
|
|
# Prevents URIs that include the front controller. This will 404:
|
|
# http://domain.tld/app.php/some-path
|
|
# Remove the internal directive to allow URIs like this
|
|
internal;
|
|
}
|
|
|
|
# return 404 for all other php files not matching the front controller
|
|
# this prevents access to other php files you don't want to be accessible.
|
|
location ~ \.php$ {
|
|
return 404;
|
|
}
|
|
|
|
error_log /var/log/nginx/wallabag_error.log;
|
|
access_log /var/log/nginx/wallabag_access.log;
|
|
}
|
|
EOF
|
|
|
|
lxc exec $CONTAINER -- rm /etc/nginx/sites-enabled/default
|
|
lxc exec $CONTAINER -- ln -s ../sites-available/wallabag /etc/nginx/sites-enabled/wallabag
|
|
lxc exec $CONTAINER -- systemctl restart nginx.service
|