2022-04-20 00:29:47 +02:00
|
|
|
#!/usr/bin/bash
|
|
|
|
source /etc/os-release
|
|
|
|
|
2022-05-03 15:41:14 +02:00
|
|
|
# Create system users
|
|
|
|
useradd -U -r -s /usr/sbin/nologin nginx
|
|
|
|
useradd -U -r -s /usr/sbin/nologin php-niver
|
|
|
|
useradd -U -r -s /usr/sbin/nologin php-errors
|
|
|
|
useradd -U -r -s /usr/sbin/nologin sftpgo
|
|
|
|
|
|
|
|
# Set proper permissions
|
|
|
|
|
2022-05-03 19:18:09 +02:00
|
|
|
chown -R knot:knot /var/lib/knot/confdb
|
|
|
|
chmod -R u=rwX,g=rwX,o= /var/lib/knot/confdb
|
2022-05-03 15:41:14 +02:00
|
|
|
usermod -aG knot php-niver
|
|
|
|
|
|
|
|
chown -R knot:knot /var/log/knot
|
|
|
|
chmod -R 700 /var/log/knot
|
|
|
|
|
|
|
|
chown -R php-niver:knot /srv/ns
|
|
|
|
chmod -R 770 /srv/ns
|
|
|
|
|
|
|
|
chown -R php-niver:php-niver /etc/nginx/ht
|
|
|
|
|
|
|
|
chown -R sftpgo:sftpgo /etc/sftpgo
|
2022-05-31 23:56:38 +02:00
|
|
|
chmod -R u=rX,g=rX,o=rX /etc/sftpgo
|
|
|
|
chmod u=r,g=,o= /etc/sftpgo/ed25519
|
2022-05-03 15:41:14 +02:00
|
|
|
|
2022-05-06 14:08:38 +02:00
|
|
|
chown -R php-niver:sftpgo /srv/ht
|
2022-05-03 15:41:14 +02:00
|
|
|
chmod -R u=rwX,g=rwX,o=rX /srv/ht
|
|
|
|
|
2022-05-06 14:08:38 +02:00
|
|
|
if [[ $ID = "debian" ]]; then
|
2022-06-10 03:20:19 +02:00
|
|
|
chown -R php-niver:debian-tor /etc/tor
|
2022-05-06 14:08:38 +02:00
|
|
|
else
|
2022-06-10 03:20:19 +02:00
|
|
|
chown -R php-niver:tor /etc/tor
|
2022-05-06 14:08:38 +02:00
|
|
|
fi
|
2022-06-10 03:20:19 +02:00
|
|
|
chmod -R u=rwX,g=rX,o= /etc/tor
|
2022-05-05 02:03:01 +02:00
|
|
|
|
2022-05-06 14:08:38 +02:00
|
|
|
chmod u=rX,g=rX,o=rX /srv/php
|
2022-05-03 15:41:14 +02:00
|
|
|
|
|
|
|
chown -R php-errors:nginx /srv/php/errors
|
2022-05-06 14:08:38 +02:00
|
|
|
chmod -R u=rX,g=rX,o= /srv/php/errors
|
2022-05-03 15:41:14 +02:00
|
|
|
|
|
|
|
chown -R php-niver:nginx /srv/php/niver
|
|
|
|
chmod -R u=rX,g=rX,o=X /srv/php/niver
|
2022-06-10 03:20:19 +02:00
|
|
|
chmod -R u=rwX,g=,o= /srv/php/niver/db
|
2022-05-03 15:41:14 +02:00
|
|
|
|
|
|
|
# Load configuration in Knot database
|
|
|
|
sudo -u knot knotc conf-import /etc/knot/knot.conf
|
|
|
|
|
2022-05-05 02:03:01 +02:00
|
|
|
# PHP paths unification across distributions
|
|
|
|
|
2022-05-03 15:41:14 +02:00
|
|
|
export PHP_INI=/etc/php/php.ini
|
|
|
|
|
|
|
|
if [[ $ID = "debian" ]]; then
|
2022-05-09 02:39:53 +02:00
|
|
|
rm /etc/php/8.1/fpm/php-fpm.conf
|
|
|
|
ln -s /etc/php/php-fpm.conf /etc/php/8.1/fpm/php-fpm.conf
|
|
|
|
ln -s /etc/php/php-fpm.d/ /etc/php/8.1/fpm/pool.d
|
2022-05-03 15:41:14 +02:00
|
|
|
|
2022-05-09 02:39:53 +02:00
|
|
|
export PHP_INI=/etc/php/8.1/fpm/php.ini
|
2022-05-03 15:41:14 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Configure PHP-FPM properly
|
|
|
|
|
|
|
|
cat >> $PHP_INI << EOF
|
|
|
|
expose_php = Off
|
|
|
|
display_errors = On
|
|
|
|
extension = pdo_sqlite
|
|
|
|
EOF
|
|
|
|
|
2022-06-10 03:20:19 +02:00
|
|
|
# Configure Tor
|
2022-06-09 03:29:41 +02:00
|
|
|
|
|
|
|
if [[ $ID = "debian" ]]; then
|
2022-06-10 03:20:19 +02:00
|
|
|
sed -i 's/User tor/User debian-tor/' /etc/tor/torrc
|
|
|
|
sed -i 's/reload tor/reload tor@default/' /etc/sudoers.d/niver
|
|
|
|
sed -i 's/ALL=(tor)/ALL=(debian-tor)/' /etc/sudoers.d/niver
|
|
|
|
sed -i 's/tor_service = "tor"/tor_service = "tor@default"/' /srv/php/niver/config.ini
|
|
|
|
sed -i 's/tor_user = "tor"/tor_user = "debian-tor"/' /srv/php/niver/config.ini
|
2022-05-05 02:03:01 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Start SystemD services at startup
|
|
|
|
|
2022-05-03 15:41:14 +02:00
|
|
|
systemctl enable sftpgo
|
|
|
|
|
2022-04-20 00:29:47 +02:00
|
|
|
if [[ $ID = "arch" ]]; then
|
|
|
|
systemctl enable sshd
|
|
|
|
systemctl enable knot
|
|
|
|
systemctl enable nginx
|
2022-05-04 17:45:05 +02:00
|
|
|
systemctl enable tor
|
2022-04-20 00:29:47 +02:00
|
|
|
systemctl enable php-fpm
|
|
|
|
fi
|