Skip to content

Instantly share code, notes, and snippets.

@notfood
Last active March 17, 2023 21:15
Show Gist options
  • Save notfood/ce13ffa4f2bcb5e28eda0da637956f00 to your computer and use it in GitHub Desktop.
Save notfood/ce13ffa4f2bcb5e28eda0da637956f00 to your computer and use it in GitHub Desktop.
Script to install Drawpile Server on Centos 8
#!/bin/sh
# Installs drawpile-server, drawpile-listserver and nginx
# You can change the hostname.domain here. Used by drawpile-server.
DPHOSTNAME=$(hostname -f)
# You can change the external ip address here. Default is Google's VPC external ip. Used by drawpile-server and nginx.
EXTERNALIP=$(curl -s -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip)
echo CTRL+C to cancel, any key to continue x3.
read -p "\n== Installing Drawpile =="
sudo dnf config-manager --set-enabled powertools
sudo yum -y install policycoreutils-python-utils
sudo yum -y install epel-release
sudo yum -y install git make cmake extra-cmake-modules gcc-c++ qt5-qtbase-devel kf5-karchive-devel libsodium-devel qt5-qtsvg-devel libmicrohttpd-devel
git clone https://github.com/drawpile/Drawpile
mkdir Drawpile/build && cd "$_"
cmake .. -DCLIENT=off -DSERVERGUI=off -DINSTALL_DOC=off -DTHICKSRV=on -DTOOLS=on -DCMAKE_BUILD_TYPE=Release
make
sudo cp bin/drawpile-* /usr/local/bin/
sudo useradd -r drawpile -d /var/lib/drawpile
sudo mkdir -p /var/lib/drawpile/sessions
sudo chown drawpile:drawpile -R /var/lib/drawpile
cat <<EOF | sudo tee /etc/systemd/system/drawpile.service
[Unit]
Description=Drawpile dedicated server
After=network.target
Documentation=man:drawpile-srv
[Service]
ExecStart=/usr/local/bin/drawpile-srv --local-host $DPHOSTNAME --database /var/lib/drawpile/config.db --sessions /var/lib/drawpile/sessions --web-admin-port 27780 --extauth https://drawpile.net/api/ext-auth/
Type=simple
Restart=on-failure
User=drawpile
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable --now drawpile
read -p "== Installing listserver =="
cd /tmp
cat <<EOF | sudo -u drawpile tee /var/lib/drawpile/listserver.cfg
database="none"
includeservers=["http://localhost:27780/api"]
EOF
sudo yum -y install golang
sudo -u drawpile go get github.com/drawpile/listserver
cat <<EOF | sudo tee /etc/systemd/system/drawpile-listserver.service
[Unit]
Description=Drawpile statistics proxy
After=network.target
[Service]
ExecStart=/var/lib/drawpile/go/bin/listserver -c /var/lib/drawpile/listserver.cfg
User=drawpile
[Install]
WantedBy=multi-user.target
EOF
sudo semanage fcontext -a -t bin_t "/var/lib/drawpile/go/bin/(.*)"
sudo restorecon -R /var/lib/drawpile/go/bin
sudo systemctl enable --now drawpile-listserver
read -p "== Installing Nginx =="
sudo yum -y install nginx unzip
sudo mkdir -p /var/www/html && cd "$_"
curl -L https://github.com/drawpile/dpserver/tarball/master | sudo tar xz --strip-components 2 --wildcards "*/public_html"
cat <<EOF | sudo tee /etc/nginx/conf.d/localsite.conf
server {
listen *:80;
listen [::]:80;
server_name $DPHOSTNAME;
server_name $EXTERNALIP;
root /var/www/html;
location / {
try_files \$uri \$uri/ =404;
}
location /admin/ {
auth_basic "admin";
auth_basic_user_file /etc/nginx/htpasswd;
try_files \$uri /admin/index.html =404;
location /admin/api/ {
proxy_pass http://localhost:27780/api/;
proxy_redirect default;
}
}
location /listing/ {
proxy_pass http://localhost:8080/;
proxy_redirect default;
proxy_set_header X-Real-IP \$remote_addr;
}
}
EOF
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html(/.*)?"
sudo restorecon -R /var/www/html
sudo setsebool httpd_can_network_connect 1 -P
sudo systemctl enable --now nginx
echo Create a password to access the admin panel under http://$EXTERNALIP/admin/api
sudo sh -c "openssl passwd -apr1" | sudo tee -a /etc/nginx/htpasswd
sudo sed -i -e 's/^/admin:/' /etc/nginx/htpasswd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment