Added scripts
This commit is contained in:
		@@ -1,3 +1,3 @@
 | 
			
		||||
# lxd-selfhosting-scripts
 | 
			
		||||
 | 
			
		||||
Provisionning bash scripts collection used to deploy some self hosted applications in LXD containers
 | 
			
		||||
Provisionning bash scripts collection used to deploy some self hosted applications in LXD containers
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										58
									
								
								install-gogs.bash
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										58
									
								
								install-gogs.bash
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,58 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONTAINER=$1
 | 
			
		||||
 | 
			
		||||
APPNAME="gogs"
 | 
			
		||||
APPURL="wget https://cdn.gogs.io/0.11.4/linux_amd64.tar.gz"
 | 
			
		||||
 | 
			
		||||
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 wget git
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y nginx
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y postgresql
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres <<< "createuser ${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres <<< "createdb --owner=${APPNAME} ${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres --shell /usr/bin/psql <<< "ALTER USER \"${APPNAME}\" WITH PASSWORD \'${APPNAME}\';"
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- useradd -m --shell /bin/bash ${APPNAME}
 | 
			
		||||
lxc exec $CONTAINER -- usermod --groups sudo --append ${APPNAME}
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- su --login ${APPNAME} --command "wget ${APPURL}"
 | 
			
		||||
lxc exec $CONTAINER -- su --login ${APPNAME} --command "tar vxzf linux_amd64.tar.gz"
 | 
			
		||||
 | 
			
		||||
lxc file edit $CONTAINER/etc/systemd/system/${APPNAME}.service <<EOF
 | 
			
		||||
[Unit]
 | 
			
		||||
Description=Gogs (Go Git Service)
 | 
			
		||||
After=syslog.target
 | 
			
		||||
After=network.target
 | 
			
		||||
After=postgresql.service
 | 
			
		||||
After=nginx.service
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
Type=simple
 | 
			
		||||
User=${APPNAME}
 | 
			
		||||
Group=${APPNAME}
 | 
			
		||||
WorkingDirectory=/home/${APPNAME}/${APPNAME}
 | 
			
		||||
ExecStart=/home/${APPNAME}/${APPNAME}/${APPNAME} web
 | 
			
		||||
Restart=always
 | 
			
		||||
Environment=USER=${APPNAME} HOME=/home/${APPNAME}
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=multi-user.target
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER systemctl enable ${APPNAME}
 | 
			
		||||
lxc exec $CONTAINER systemctl start ${APPNAME}
 | 
			
		||||
 | 
			
		||||
# lxc restart $CONTAINER
 | 
			
		||||
							
								
								
									
										115
									
								
								install-pydio.bash
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										115
									
								
								install-pydio.bash
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,115 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONTAINER=$1
 | 
			
		||||
 | 
			
		||||
APPNAME="pydio"
 | 
			
		||||
APPURL="https://download.pydio.com/pub/core/archives/pydio-core-7.0.4.tar.gz"
 | 
			
		||||
 | 
			
		||||
TMPDIR="/tmp"
 | 
			
		||||
INSTALLDIR="/var/www"
 | 
			
		||||
 | 
			
		||||
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}"
 | 
			
		||||
 | 
			
		||||
# Update packages
 | 
			
		||||
lxc exec $CONTAINER -- apt update
 | 
			
		||||
 | 
			
		||||
# Install packages
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y curl wget tar unzip
 | 
			
		||||
 | 
			
		||||
# Install database
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y postgresql
 | 
			
		||||
 | 
			
		||||
# Create database
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres <<< "createuser ${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres <<< "createdb --owner=${APPNAME} ${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres --shell /usr/bin/psql <<< "ALTER USER \"${APPNAME}\" WITH PASSWORD '${APPNAME}';"
 | 
			
		||||
 | 
			
		||||
# Install PHP
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-intl
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-mbstring
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-xml
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-gd
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-pgsql
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-curl
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-mail php-mail-mime php-mail-mimedecode
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-sabre-dav
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y redis-server php-redis
 | 
			
		||||
 | 
			
		||||
# Configure PHP
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e "s|;date.timezone.*|date.timezone = \"${TIMEZONE}\"|" /etc/php/7.0/fpm/php.ini
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e 's/^\(output_buffering\) = .*$/\1 = Off/g'            /etc/php/7.0/fpm/php.ini
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e 's/^\(file_uploads\) = .*$/\1 = On/g'                 /etc/php/7.0/fpm/php.ini
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e 's/^\(post_max_size\) = .*$/\1 = 2G/g'                /etc/php/7.0/fpm/php.ini
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e 's/^\(upload_max_filesize\) = .*$/\1 =2G/g'           /etc/php/7.0/fpm/php.ini
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e 's/^\(max_execution_time\) = .*$/\1 = 300/g'          /etc/php/7.0/fpm/php.ini
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e 's/^\(max_input_time\) = .*$/\1 = 300/g'              /etc/php/7.0/fpm/php.ini
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e 's/^\(memory_limit\) = .*$/\1 = 256M/g'               /etc/php/7.0/fpm/php.ini
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod intl
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod mbstring
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod xml
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod dom
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod gd
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod pdo
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod curl
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod opcache
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod redis
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- systemctl restart php7.0-fpm.service
 | 
			
		||||
 | 
			
		||||
# Install Nginx
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y nginx
 | 
			
		||||
 | 
			
		||||
# Configure Nginx
 | 
			
		||||
lxc file edit "$CONTAINER/etc/nginx/sites-available/${APPNAME}" <<EOF
 | 
			
		||||
server {
 | 
			
		||||
 | 
			
		||||
  server_name ${APPNAME}.${DOMAIN};
 | 
			
		||||
 | 
			
		||||
  root ${INSTALLDIR}/${APPNAME};
 | 
			
		||||
 | 
			
		||||
  access_log /var/log/nginx/${APPNAME}.access.log;
 | 
			
		||||
  error_log /var/log/nginx/${APPNAME}.error.log;
 | 
			
		||||
 | 
			
		||||
  index index.php index.html;
 | 
			
		||||
 | 
			
		||||
  client_max_body_size 2G;
 | 
			
		||||
 | 
			
		||||
  # Prevent Clickjacking
 | 
			
		||||
  add_header X-Frame-Options "SAMEORIGIN";
 | 
			
		||||
 | 
			
		||||
  # Manually deny some paths to ensure Pydio security
 | 
			
		||||
  location ~* ^/(?:\.|conf|data/(?:files|personal|logs|plugins|tmp|cache)|plugins/editor.zoho/agent/files) {
 | 
			
		||||
    deny all;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  location ~ \.php\$ {
 | 
			
		||||
    try_files \$uri =404;
 | 
			
		||||
    include /etc/nginx/fastcgi_params;
 | 
			
		||||
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
 | 
			
		||||
    fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
 | 
			
		||||
    fastcgi_index index.php;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- rm /etc/nginx/sites-enabled/default
 | 
			
		||||
lxc exec $CONTAINER -- ln -s "../sites-available/${APPNAME}" "/etc/nginx/sites-enabled/${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- systemctl restart nginx.service
 | 
			
		||||
 | 
			
		||||
# Install Web App
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "cd ${TMPDIR} && wget ${APPURL}"
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "tar vxzf ${TMPDIR}/${APPNAME}-*.tar.gz -C ${INSTALLDIR}"
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "mv ${INSTALLDIR}/${APPNAME}-* ${INSTALLDIR}/${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- chown -R "www-data:www-data" "${INSTALLDIR}/${APPNAME}"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										100
									
								
								install-rainloop.bash
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										100
									
								
								install-rainloop.bash
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,100 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONTAINER=$1
 | 
			
		||||
 | 
			
		||||
APPNAME="rainloop"
 | 
			
		||||
APPURL="http://www.rainloop.net/repository/webmail/rainloop-community-latest.zip"
 | 
			
		||||
 | 
			
		||||
TMPDIR="/tmp"
 | 
			
		||||
INSTALLDIR="/var/www"
 | 
			
		||||
 | 
			
		||||
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 wget tar unzip
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y aspell aspell-fr hunspell hunspell-fr enchant
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y nginx
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y postgresql
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-curl
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-intl
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-json
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-xml
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-pgsql
 | 
			
		||||
 | 
			
		||||
# Configure PHP
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e "s|;date.timezone.*|date.timezone = \"${TIMEZONE}\"|" /etc/php/7.0/fpm/php.ini
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod curl
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod iconv
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod json
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod xml
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod dom
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod pdo
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- systemctl restart php7.0-fpm.service
 | 
			
		||||
 | 
			
		||||
# Create database
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres <<< "createuser ${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres <<< "createdb --owner=${APPNAME} ${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres --shell /usr/bin/psql <<< "ALTER USER \"${APPNAME}\" WITH PASSWORD '${APPNAME}';"
 | 
			
		||||
 | 
			
		||||
# Install web app
 | 
			
		||||
lxc exec $CONTAINER -- mkdir "${INSTALLDIR}/${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- chown -R "www-data:www-data" "${INSTALLDIR}/${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "cd ${INSTALLDIR}/${APPNAME} && curl -sL https://repository.rainloop.net/installer.php | php"
 | 
			
		||||
 | 
			
		||||
# Configure Nginx
 | 
			
		||||
lxc file edit "$CONTAINER/etc/nginx/sites-available/${APPNAME}" <<EOF
 | 
			
		||||
server {
 | 
			
		||||
 | 
			
		||||
  server_name ${APPNAME}.${DOMAIN};
 | 
			
		||||
 | 
			
		||||
  root ${INSTALLDIR}/${APPNAME};
 | 
			
		||||
 | 
			
		||||
  index index.php index.html;
 | 
			
		||||
 | 
			
		||||
  location = /robots.txt {
 | 
			
		||||
    allow all;
 | 
			
		||||
    log_not_found off;
 | 
			
		||||
    access_log off;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  location ^~ /data {
 | 
			
		||||
    deny all;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
 | 
			
		||||
  location ~ /\. {
 | 
			
		||||
    deny all;
 | 
			
		||||
    access_log off;
 | 
			
		||||
    log_not_found off;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  location ~ \.php\$ {
 | 
			
		||||
    try_files \$uri =404;
 | 
			
		||||
    include /etc/nginx/fastcgi_params;
 | 
			
		||||
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
 | 
			
		||||
    fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
 | 
			
		||||
    fastcgi_index index.php;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  error_log /var/log/nginx/${APPNAME}_error.log;
 | 
			
		||||
  access_log /var/log/nginx/${APPNAME}_access.log;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- rm /etc/nginx/sites-enabled/default
 | 
			
		||||
lxc exec $CONTAINER -- ln -s "../sites-available/${APPNAME}" "/etc/nginx/sites-enabled/${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- systemctl restart nginx.service
 | 
			
		||||
							
								
								
									
										120
									
								
								install-roundcubemail.bash
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										120
									
								
								install-roundcubemail.bash
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,120 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONTAINER=$1
 | 
			
		||||
 | 
			
		||||
APPNAME="roundcubemail"
 | 
			
		||||
APPURL="https://github.com/roundcube/roundcubemail/releases/download/1.2.4/roundcubemail-1.2.4-complete.tar.gz"
 | 
			
		||||
 | 
			
		||||
TMPDIR="/tmp"
 | 
			
		||||
INSTALLDIR="/var/www"
 | 
			
		||||
 | 
			
		||||
DOMAIN="logerais.com"
 | 
			
		||||
TIMEZONE="Europe/Paris"
 | 
			
		||||
 | 
			
		||||
if [ -z "$CONTAINER" ]; then echo "Missing parameter"; exit 1 ; fi
 | 
			
		||||
 | 
			
		||||
# Configure timezone
 | 
			
		||||
lxc file edit "$CONTAINER/etc/timezone" <<< "${TIMEZONE}"
 | 
			
		||||
 | 
			
		||||
# Install Packages
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt update
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y curl wget
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y aspell aspell-fr hunspell hunspell-fr enchant
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y nginx
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y postgresql
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-xml
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-json
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-mbstring
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-intl
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-ldap
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-mcrypt
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-enchant
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-pgsql
 | 
			
		||||
 | 
			
		||||
# Install Web App
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "cd ${TMPDIR} && wget ${APPURL}"
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "tar vxzf ${TMPDIR}/${APPNAME}-*.tar.gz -C ${INSTALLDIR}"
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "mv ${INSTALLDIR}/${APPNAME}-* ${INSTALLDIR}/${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- chown -R "www-data:www-data" "${INSTALLDIR}/${APPNAME}"
 | 
			
		||||
 | 
			
		||||
# Create Database
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres <<< "createuser ${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres <<< "createdb --owner=${APPNAME} ${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- su --login postgres --shell /usr/bin/psql <<< "ALTER USER \"${APPNAME}\" WITH PASSWORD '${APPNAME}';"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Configure PHP
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e "s|;date.timezone.*|date.timezone = \"${TIMEZONE}\"|" /etc/php/7.0/fpm/php.ini
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod dom
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod session
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod xml
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod json
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod pdo
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod mbstring
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod fileinfo
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod iconv
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod intl
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod exif
 | 
			
		||||
lxc exec $CONTAINER -- phpenmod ldap
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- systemctl restart php7.0-fpm.service
 | 
			
		||||
 | 
			
		||||
# Configure Nginx
 | 
			
		||||
 | 
			
		||||
lxc file edit "$CONTAINER/etc/nginx/sites-available/${APPNAME}" <<EOF
 | 
			
		||||
server {
 | 
			
		||||
 | 
			
		||||
  server_name ${APPNAME}.${DOMAIN};
 | 
			
		||||
 | 
			
		||||
  root ${INSTALLDIR}/${APPNAME};
 | 
			
		||||
 | 
			
		||||
  index index.php index.html;
 | 
			
		||||
 | 
			
		||||
  location = /robots.txt {
 | 
			
		||||
    allow all;
 | 
			
		||||
    log_not_found off;
 | 
			
		||||
    access_log off;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
 | 
			
		||||
    deny all;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  location ~ ^/(config|temp|logs)/ {
 | 
			
		||||
    deny all;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  location ~ ^/(bin|SQL)/ {
 | 
			
		||||
    deny all;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
 | 
			
		||||
  location ~ /\. {
 | 
			
		||||
    deny all;
 | 
			
		||||
    access_log off;
 | 
			
		||||
    log_not_found off;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  location ~ \.php\$ {
 | 
			
		||||
    try_files \$uri =404;
 | 
			
		||||
    include /etc/nginx/fastcgi_params;
 | 
			
		||||
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
 | 
			
		||||
    fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
 | 
			
		||||
    fastcgi_index index.php;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  error_log /var/log/nginx/${APPNAME}_error.log;
 | 
			
		||||
  access_log /var/log/nginx/${APPNAME}_access.log;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- rm /etc/nginx/sites-enabled/default
 | 
			
		||||
lxc exec $CONTAINER -- ln -s "../sites-available/${APPNAME}" "/etc/nginx/sites-enabled/${APPNAME}"
 | 
			
		||||
lxc exec $CONTAINER -- systemctl restart nginx.service
 | 
			
		||||
							
								
								
									
										13
									
								
								install-shinken.bash
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								install-shinken.bash
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONTAINER=$1
 | 
			
		||||
 | 
			
		||||
if [ -z "$CONTAINER" ]; then echo "Missing parameter"; exit 1 ; fi
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt update
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y python-pip python-pycurl python-cherrypy3 python-crypto python-passlib
 | 
			
		||||
lxc exec $CONTAINER -- useradd -m -s /bin/bash shinken
 | 
			
		||||
lxc exec $CONTAINER -- pip install shinken
 | 
			
		||||
lxc exec $CONTAINER -- update-rc.d shinken defaults
 | 
			
		||||
lxc exec $CONTAINER -- service shinken start
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										14
									
								
								install-tick.bash
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										14
									
								
								install-tick.bash
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONTAINER=$1
 | 
			
		||||
 | 
			
		||||
if [ -z "$CONTAINER" ]; then echo "Missing parameter"; exit 1 ; fi
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt update
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y wget curl
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- bash -c 'curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -'
 | 
			
		||||
lxc exec $CONTAINER -- bash -c 'source /etc/lsb-release && echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" > /etc/apt/sources.list.d/influxdb.list'
 | 
			
		||||
lxc exec $CONTAINER -- apt update
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y telegraf influxdb chronograf kapacitor
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										101
									
								
								install-wallabag.bash
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										101
									
								
								install-wallabag.bash
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,101 @@
 | 
			
		||||
#!/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
 | 
			
		||||
							
								
								
									
										160
									
								
								install-wordpress-multisite.bash
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										160
									
								
								install-wordpress-multisite.bash
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,160 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONTAINER=$1
 | 
			
		||||
 | 
			
		||||
APPNAME="wordpress"
 | 
			
		||||
APPURL="https://fr.wordpress.org/wordpress-4.7.3-fr_FR.zip"
 | 
			
		||||
 | 
			
		||||
TMPDIR="/tmp"
 | 
			
		||||
INSTALLDIR="/var/www"
 | 
			
		||||
 | 
			
		||||
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 wget tar unzip
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y aspell aspell-fr hunspell hunspell-fr enchant
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y apache2 libapache2-mod-php
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y mariadb-client mariadb-server
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-curl php-intl php-json php-xml php-gd
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-mysql
 | 
			
		||||
 | 
			
		||||
# Install Web App
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "cd ${TMPDIR} && wget ${APPURL}"
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "unzip ${TMPDIR}/${APPNAME}-*.zip -d ${INSTALLDIR}"
 | 
			
		||||
lxc exec $CONTAINER -- chown -R "www-data:www-data" "${INSTALLDIR}/${APPNAME}"
 | 
			
		||||
 | 
			
		||||
# Create Database
 | 
			
		||||
lxc exec $CONTAINER -- mysql <<< "CREATE USER '${APPNAME}'@'localhost' IDENTIFIED BY '${APPNAME}';"
 | 
			
		||||
lxc exec $CONTAINER -- mysql <<< "CREATE DATABASE ${APPNAME};"
 | 
			
		||||
lxc exec $CONTAINER -- mysql <<< "GRANT ALL PRIVILEGES ON ${APPNAME}.* to ${APPNAME}@localhost;"
 | 
			
		||||
lxc exec $CONTAINER -- mysql <<< "FLUSH PRIVILEGES;"
 | 
			
		||||
 | 
			
		||||
# Configure PHP
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e "s|;date.timezone.*|date.timezone = \"${TIMEZONE}\"|" /etc/php/7.0/apache2/php.ini
 | 
			
		||||
 | 
			
		||||
# Configure Apache
 | 
			
		||||
lxc exec $CONTAINER -- a2enmod rewrite
 | 
			
		||||
lxc file edit "$CONTAINER/etc/apache2/sites-available/${APPNAME}.conf" <<EOF
 | 
			
		||||
<VirtualHost *:80>
 | 
			
		||||
 | 
			
		||||
    ServerName ${APPNAME}.${DOMAIN}
 | 
			
		||||
    ServerAdmin admin@${DOMAIN}
 | 
			
		||||
    DocumentRoot /var/www/${APPNAME}
 | 
			
		||||
 | 
			
		||||
    ErrorLog \${APACHE_LOG_DIR}/${APPNAME}.error.log
 | 
			
		||||
    CustomLog \${APACHE_LOG_DIR}/${APPNAME}.access.log combined
 | 
			
		||||
 | 
			
		||||
</VirtualHost>
 | 
			
		||||
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
#lxc exec $CONTAINER -- rm /etc/apache2/sites-enabled/default
 | 
			
		||||
lxc exec $CONTAINER -- ln -s "../sites-available/${APPNAME}.conf" "/etc/apache2/sites-enabled/${APPNAME}.conf"
 | 
			
		||||
lxc exec $CONTAINER -- systemctl reload apache2.service
 | 
			
		||||
 | 
			
		||||
# Configure wordpress
 | 
			
		||||
lxc file edit "$CONTAINER/${INSTALLDIR}/${APPNAME}/wp-config.php" <<EOF
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * La configuration de base de votre installation WordPress.
 | 
			
		||||
 *
 | 
			
		||||
 * Ce fichier contient les réglages de configuration suivants : réglages MySQL,
 | 
			
		||||
 * préfixe de table, clés secrètes, langue utilisée, et ABSPATH.
 | 
			
		||||
 * Vous pouvez en savoir plus à leur sujet en allant sur
 | 
			
		||||
 * {@link http://codex.wordpress.org/fr:Modifier_wp-config.php Modifier
 | 
			
		||||
 * wp-config.php}. C’est votre hébergeur qui doit vous donner vos
 | 
			
		||||
 * codes MySQL.
 | 
			
		||||
 *
 | 
			
		||||
 * Ce fichier est utilisé par le script de création de wp-config.php pendant
 | 
			
		||||
 * le processus d’installation. Vous n’avez pas à utiliser le site web, vous
 | 
			
		||||
 * pouvez simplement renommer ce fichier en "wp-config.php" et remplir les
 | 
			
		||||
 * valeurs.
 | 
			
		||||
 *
 | 
			
		||||
 * @package WordPress
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 /* Multisite */
 | 
			
		||||
 define('WP_ALLOW_MULTISITE', true);
 | 
			
		||||
 | 
			
		||||
// ** Réglages MySQL - Votre hébergeur doit vous fournir ces informations. ** //
 | 
			
		||||
/** Nom de la base de données de WordPress. */
 | 
			
		||||
define('DB_NAME', '${APPNAME}');
 | 
			
		||||
 | 
			
		||||
/** Utilisateur de la base de données MySQL. */
 | 
			
		||||
define('DB_USER', '${APPNAME}');
 | 
			
		||||
 | 
			
		||||
/** Mot de passe de la base de données MySQL. */
 | 
			
		||||
define('DB_PASSWORD', '${APPNAME}');
 | 
			
		||||
 | 
			
		||||
/** Adresse de l’hébergement MySQL. */
 | 
			
		||||
define('DB_HOST', 'localhost');
 | 
			
		||||
 | 
			
		||||
/** Jeu de caractères à utiliser par la base de données lors de la création des tables. */
 | 
			
		||||
define('DB_CHARSET', 'utf8');
 | 
			
		||||
 | 
			
		||||
/** Type de collation de la base de données.
 | 
			
		||||
  * N’y touchez que si vous savez ce que vous faites.
 | 
			
		||||
  */
 | 
			
		||||
define('DB_COLLATE', '');
 | 
			
		||||
 | 
			
		||||
/**#@+
 | 
			
		||||
 * Clés uniques d’authentification et salage.
 | 
			
		||||
 *
 | 
			
		||||
 * Remplacez les valeurs par défaut par des phrases uniques !
 | 
			
		||||
 * Vous pouvez générer des phrases aléatoires en utilisant
 | 
			
		||||
 * {@link https://api.wordpress.org/secret-key/1.1/salt/ le service de clefs secrètes de WordPress.org}.
 | 
			
		||||
 * Vous pouvez modifier ces phrases à n’importe quel moment, afin d’invalider tous les cookies existants.
 | 
			
		||||
 * Cela forcera également tous les utilisateurs à se reconnecter.
 | 
			
		||||
 *
 | 
			
		||||
 * @since 2.6.0
 | 
			
		||||
 */
 | 
			
		||||
$(curl https://api.wordpress.org/secret-key/1.1/salt/)
 | 
			
		||||
/**#@-*/
 | 
			
		||||
/**
 | 
			
		||||
 * Préfixe de base de données pour les tables de WordPress.
 | 
			
		||||
 *
 | 
			
		||||
 * Vous pouvez installer plusieurs WordPress sur une seule base de données
 | 
			
		||||
 * si vous leur donnez chacune un préfixe unique.
 | 
			
		||||
 * N’utilisez que des chiffres, des lettres non-accentuées, et des caractères soulignés !
 | 
			
		||||
 */
 | 
			
		||||
\$table_prefix  = 'wp_';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Pour les développeurs : le mode déboguage de WordPress.
 | 
			
		||||
 *
 | 
			
		||||
 * En passant la valeur suivante à "true", vous activez l’affichage des
 | 
			
		||||
 * notifications d’erreurs pendant vos essais.
 | 
			
		||||
 * Il est fortemment recommandé que les développeurs d’extensions et
 | 
			
		||||
 * de thèmes se servent de WP_DEBUG dans leur environnement de
 | 
			
		||||
 * développement.
 | 
			
		||||
 *
 | 
			
		||||
 * Pour plus d’information sur les autres constantes qui peuvent être utilisées
 | 
			
		||||
 * pour le déboguage, rendez-vous sur le Codex.
 | 
			
		||||
 *
 | 
			
		||||
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 | 
			
		||||
 */
 | 
			
		||||
define('WP_DEBUG', false);
 | 
			
		||||
 | 
			
		||||
/* C’est tout, ne touchez pas à ce qui suit ! */
 | 
			
		||||
 | 
			
		||||
/** Chemin absolu vers le dossier de WordPress. */
 | 
			
		||||
if ( !defined('ABSPATH') )
 | 
			
		||||
        define('ABSPATH', dirname(__FILE__) . '/');
 | 
			
		||||
 | 
			
		||||
/** Réglage des variables de WordPress et de ses fichiers inclus. */
 | 
			
		||||
require_once(ABSPATH . 'wp-settings.php');
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- chown -R "www-data:www-data" "${INSTALLDIR}/${APPNAME}"
 | 
			
		||||
							
								
								
									
										157
									
								
								install-wordpress.bash
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										157
									
								
								install-wordpress.bash
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,157 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONTAINER=$1
 | 
			
		||||
 | 
			
		||||
APPNAME="wordpress"
 | 
			
		||||
APPURL="https://fr.wordpress.org/wordpress-4.7.3-fr_FR.zip"
 | 
			
		||||
 | 
			
		||||
TMPDIR="/tmp"
 | 
			
		||||
INSTALLDIR="/var/www"
 | 
			
		||||
 | 
			
		||||
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 wget tar unzip
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y aspell aspell-fr hunspell hunspell-fr enchant
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y apache2 libapache2-mod-php
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y mariadb-client mariadb-server
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-curl php-intl php-json php-xml php-gd
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y php-mysql
 | 
			
		||||
 | 
			
		||||
# Install Web App
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "cd ${TMPDIR} && wget ${APPURL}"
 | 
			
		||||
lxc exec $CONTAINER -- bash <<< "unzip ${TMPDIR}/${APPNAME}-*.zip -d ${INSTALLDIR}"
 | 
			
		||||
lxc exec $CONTAINER -- chown -R "www-data:www-data" "${INSTALLDIR}/${APPNAME}"
 | 
			
		||||
 | 
			
		||||
# Create Database
 | 
			
		||||
lxc exec $CONTAINER -- mysql <<< "CREATE USER '${APPNAME}'@'localhost' IDENTIFIED BY '${APPNAME}';"
 | 
			
		||||
lxc exec $CONTAINER -- mysql <<< "CREATE DATABASE ${APPNAME};"
 | 
			
		||||
lxc exec $CONTAINER -- mysql <<< "GRANT ALL PRIVILEGES ON ${APPNAME}.* to ${APPNAME}@localhost;"
 | 
			
		||||
lxc exec $CONTAINER -- mysql <<< "FLUSH PRIVILEGES;"
 | 
			
		||||
 | 
			
		||||
# Configure PHP
 | 
			
		||||
lxc exec $CONTAINER -- sed -i -e "s|;date.timezone.*|date.timezone = \"${TIMEZONE}\"|" /etc/php/7.0/apache2/php.ini
 | 
			
		||||
 | 
			
		||||
# Configure Apache
 | 
			
		||||
lxc exec $CONTAINER -- a2enmod rewrite
 | 
			
		||||
lxc file edit "$CONTAINER/etc/apache2/sites-available/${APPNAME}.conf" <<EOF
 | 
			
		||||
<VirtualHost *:80>
 | 
			
		||||
 | 
			
		||||
    ServerName ${APPNAME}.${DOMAIN}
 | 
			
		||||
    ServerAdmin admin@${DOMAIN}
 | 
			
		||||
    DocumentRoot /var/www/${APPNAME}
 | 
			
		||||
 | 
			
		||||
    ErrorLog \${APACHE_LOG_DIR}/${APPNAME}.error.log
 | 
			
		||||
    CustomLog \${APACHE_LOG_DIR}/${APPNAME}.access.log combined
 | 
			
		||||
 | 
			
		||||
</VirtualHost>
 | 
			
		||||
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
#lxc exec $CONTAINER -- rm /etc/apache2/sites-enabled/default
 | 
			
		||||
lxc exec $CONTAINER -- ln -s "../sites-available/${APPNAME}.conf" "/etc/apache2/sites-enabled/${APPNAME}.conf"
 | 
			
		||||
lxc exec $CONTAINER -- systemctl reload apache2.service
 | 
			
		||||
 | 
			
		||||
# Configure wordpress
 | 
			
		||||
lxc file edit "$CONTAINER/${INSTALLDIR}/${APPNAME}/wp-config.php" <<EOF
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * La configuration de base de votre installation WordPress.
 | 
			
		||||
 *
 | 
			
		||||
 * Ce fichier contient les réglages de configuration suivants : réglages MySQL,
 | 
			
		||||
 * préfixe de table, clés secrètes, langue utilisée, et ABSPATH.
 | 
			
		||||
 * Vous pouvez en savoir plus à leur sujet en allant sur
 | 
			
		||||
 * {@link http://codex.wordpress.org/fr:Modifier_wp-config.php Modifier
 | 
			
		||||
 * wp-config.php}. C’est votre hébergeur qui doit vous donner vos
 | 
			
		||||
 * codes MySQL.
 | 
			
		||||
 *
 | 
			
		||||
 * Ce fichier est utilisé par le script de création de wp-config.php pendant
 | 
			
		||||
 * le processus d’installation. Vous n’avez pas à utiliser le site web, vous
 | 
			
		||||
 * pouvez simplement renommer ce fichier en "wp-config.php" et remplir les
 | 
			
		||||
 * valeurs.
 | 
			
		||||
 *
 | 
			
		||||
 * @package WordPress
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// ** Réglages MySQL - Votre hébergeur doit vous fournir ces informations. ** //
 | 
			
		||||
/** Nom de la base de données de WordPress. */
 | 
			
		||||
define('DB_NAME', '${APPNAME}');
 | 
			
		||||
 | 
			
		||||
/** Utilisateur de la base de données MySQL. */
 | 
			
		||||
define('DB_USER', '${APPNAME}');
 | 
			
		||||
 | 
			
		||||
/** Mot de passe de la base de données MySQL. */
 | 
			
		||||
define('DB_PASSWORD', '${APPNAME}');
 | 
			
		||||
 | 
			
		||||
/** Adresse de l’hébergement MySQL. */
 | 
			
		||||
define('DB_HOST', 'localhost');
 | 
			
		||||
 | 
			
		||||
/** Jeu de caractères à utiliser par la base de données lors de la création des tables. */
 | 
			
		||||
define('DB_CHARSET', 'utf8');
 | 
			
		||||
 | 
			
		||||
/** Type de collation de la base de données.
 | 
			
		||||
  * N’y touchez que si vous savez ce que vous faites.
 | 
			
		||||
  */
 | 
			
		||||
define('DB_COLLATE', '');
 | 
			
		||||
 | 
			
		||||
/**#@+
 | 
			
		||||
 * Clés uniques d’authentification et salage.
 | 
			
		||||
 *
 | 
			
		||||
 * Remplacez les valeurs par défaut par des phrases uniques !
 | 
			
		||||
 * Vous pouvez générer des phrases aléatoires en utilisant
 | 
			
		||||
 * {@link https://api.wordpress.org/secret-key/1.1/salt/ le service de clefs secrètes de WordPress.org}.
 | 
			
		||||
 * Vous pouvez modifier ces phrases à n’importe quel moment, afin d’invalider tous les cookies existants.
 | 
			
		||||
 * Cela forcera également tous les utilisateurs à se reconnecter.
 | 
			
		||||
 *
 | 
			
		||||
 * @since 2.6.0
 | 
			
		||||
 */
 | 
			
		||||
$(curl https://api.wordpress.org/secret-key/1.1/salt/)
 | 
			
		||||
/**#@-*/
 | 
			
		||||
/**
 | 
			
		||||
 * Préfixe de base de données pour les tables de WordPress.
 | 
			
		||||
 *
 | 
			
		||||
 * Vous pouvez installer plusieurs WordPress sur une seule base de données
 | 
			
		||||
 * si vous leur donnez chacune un préfixe unique.
 | 
			
		||||
 * N’utilisez que des chiffres, des lettres non-accentuées, et des caractères soulignés !
 | 
			
		||||
 */
 | 
			
		||||
\$table_prefix  = 'wp_';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Pour les développeurs : le mode déboguage de WordPress.
 | 
			
		||||
 *
 | 
			
		||||
 * En passant la valeur suivante à "true", vous activez l’affichage des
 | 
			
		||||
 * notifications d’erreurs pendant vos essais.
 | 
			
		||||
 * Il est fortemment recommandé que les développeurs d’extensions et
 | 
			
		||||
 * de thèmes se servent de WP_DEBUG dans leur environnement de
 | 
			
		||||
 * développement.
 | 
			
		||||
 *
 | 
			
		||||
 * Pour plus d’information sur les autres constantes qui peuvent être utilisées
 | 
			
		||||
 * pour le déboguage, rendez-vous sur le Codex.
 | 
			
		||||
 *
 | 
			
		||||
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 | 
			
		||||
 */
 | 
			
		||||
define('WP_DEBUG', false);
 | 
			
		||||
 | 
			
		||||
/* C’est tout, ne touchez pas à ce qui suit ! */
 | 
			
		||||
 | 
			
		||||
/** Chemin absolu vers le dossier de WordPress. */
 | 
			
		||||
if ( !defined('ABSPATH') )
 | 
			
		||||
        define('ABSPATH', dirname(__FILE__) . '/');
 | 
			
		||||
 | 
			
		||||
/** Réglage des variables de WordPress et de ses fichiers inclus. */
 | 
			
		||||
require_once(ABSPATH . 'wp-settings.php');
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- chown -R "www-data:www-data" "${INSTALLDIR}/${APPNAME}"
 | 
			
		||||
							
								
								
									
										17
									
								
								install-xpra.bash
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										17
									
								
								install-xpra.bash
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONTAINER=$1
 | 
			
		||||
 | 
			
		||||
if [ -z "$CONTAINER" ]; then echo "Missing parameter"; exit 1 ; fi
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt update
 | 
			
		||||
lxc exec $CONTAINER -- apt install -y xterm openssh-server
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- wget https://xpra.org/dists/trusty/main/binary-amd64/python-rencode_1.0.3-1_amd64.deb && dpkg -i python-rencode_1.0.3-1_amd64.deb
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- apt install python-gtkglext1 python-opengl python-lzo python-appindicator libswscale2 libwebp5 libx264-142 libxkbfile1 x11-xserver-utils xvfb python-numpy python-imaging
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- wget https://xpra.org/dists/trusty/main/binary-amd64/xpra_0.15.10-1_amd64.deb && dpkg -i xpra_0.15.10-1_amd64.deb
 | 
			
		||||
 | 
			
		||||
lxc exec $CONTAINER -- useradd -m -s /bin/bash xpra
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user