os-init/debian-11/apps/dokuwiki/dokuwiki.sh

65 lines
2.1 KiB
Bash
Raw Permalink Normal View History

2023-11-19 22:04:42 +00:00
#!/bin/bash
apt install -y php libapache2-mod-php php-xml
a2dissite 000-default
a2dissite default-ssl.conf
a2enmod ssl
mkdir /opt/dokuwiki
mkdir /var/www/dokuwiki
wget -O dokuwiki.tgz https://download.dokuwiki.org/src/dokuwiki/dokuwiki-rc.tgz
mkdir tmp-dokuwiki
tar xzvf dokuwiki.tgz -C ./tmp-dokuwiki/
mv ./tmp-dokuwiki/*/* /var/www/dokuwiki
mv ./tmp-dokuwiki/*/.* /var/www/dokuwiki
mv /var/www/dokuwiki/data /opt/dokuwiki/
rm -R ./tmp-dokuwiki
cp /var/www/dokuwiki/conf/local.php.dist /var/www/dokuwiki/conf/local.php
cp /var/www/dokuwiki/conf/acl.auth.php.dist /var/www/dokuwiki/conf/acl.auth.php
cp /var/www/dokuwiki/conf/users.auth.php.dist /var/www/dokuwiki/conf/users.auth.php
chown -R www-data:www-data /opt/dokuwiki
chown -R www-data:www-data /var/www/dokuwiki
sed -i 's|./data|/opt/dokuwiki/data|g' /var/www/dokuwiki/conf/dokuwiki.php
echo "\$conf['useacl'] = 1;" >> /var/www/dokuwiki/conf/local.php
echo "\$conf['superuser'] = '@admin';" >> /var/www/dokuwiki/conf/local.php
echo "$(echo "admin" | htpasswd -n -i -B admin):admin:admin@local.lan:admin" >> /var/www/dokuwiki/conf/users.auth.php
cat > /etc/apache2/sites-available/dokuwiki.conf << "EOF"
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/dokuwiki
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
EOF
systemctl reload apache2
a2ensite dokuwiki
systemctl restart apache2
if [ -f "/etc/iptables/rules.v4" ]; then
sed -i '/^-A INPUT -i lo -j ACCEPT.*/a -A INPUT -p tcp -m tcp --dport 443 -m state --state NEW -j ACCEPT' /etc/iptables/rules.v4
sed -i '/^-A INPUT -i lo -j ACCEPT.*/a # Matomo' /etc/iptables/rules.v4
iptables-restore /etc/iptables/rules.v4
fi