Gotify — Platform Notification reciever support mobile and web. mobile in ios (iGotify) and android (appnotifier)
Download script or write this script.sh
#!/bin/bash
GOTIFY="gotify-linux-amd64.zip"
LINK="https://github.com/gotify/server/releases/download/v2.1.7/${GOTIFY}"
HOME_NOTIFY="/opt/gotify"
REVERSE_PROXY_ENABLE="true"
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo "Aborting: run as root user!"
exit 1
fi
! [ -d ${HOME_NOTIFY} ] && mkdir -p ${HOME_NOTIFY} ||echo "Directory ${HOME_NOTIFY} already created"
cd ${HOME_NOTIFY}
wget -c ${LINK}
check_unzip=`command -v unzip`
if [ $? == 1 ]
then
check_apt=`command -v apt`
if [ $? == 0 ]
then
apt install unzip -y
else
yum install unzip -y
fi
fi
cd ${HOME_NOTIFY}
unzip ${GOTIFY}
rm -rf LICENSE licenses/ gotify-linux-amd64.zip
mkdir -p ${HOME_NOTIFY}/bin ${HOME_NOTIFY}/conf ${HOME_NOTIFY}/data ${HOME_NOTIFY}/systemd
mv gotify-linux-amd64 bin/gotify
cat > ${HOME_NOTIFY}/conf/config.yml<<EOF
server:
keepaliveperiodseconds: 25 # 0 = use Go default (15s); -1 = disable keepalive; set the interval in which keepalive packets will be sent. Only change this value if you know what you are doing.
listenaddr: "127.0.0.1" # the address to bind on, leave empty to bind on all addresses
port: 3111 # the port the HTTP server will listen on
ssl:
enabled: false # if https should be enabled
redirecttohttps: true # redirect to https if site is accessed by http
listenaddr: "" # the address to bind on, leave empty to bind on all addresses
port: 443 # the https port
certfile: # the cert file (leave empty when using letsencrypt)
certkey: # the cert key (leave empty when using letsencrypt)
letsencrypt:
enabled: false # if the certificate should be requested from letsencrypt
accepttos: false # if you accept the tos from letsencrypt
cache: data/certs # the directory of the cache from letsencrypt
hosts: # the hosts for which letsencrypt should request certificates
# - mydomain.tld
# - myotherdomain.tld
responseheaders: # response headers are added to every response (default: none)
# X-Custom-Header: "custom value"
cors: # Sets cors headers only when needed and provides support for multiple allowed origins. Overrides Access-Control-* Headers in response headers.
alloworigins:
# - ".+.example.com"
# - "otherdomain.com"
allowmethods:
# - "GET"
# - "POST"
allowheaders:
# - "Authorization"
# - "content-type"
stream:
pingperiodseconds: 45 # the interval in which websocket pings will be sent. Only change this value if you know what you are doing.
allowedorigins: # allowed origins for websocket connections (same origin is always allowed)
# - ".+.example.com"
# - "otherdomain.com"
database: # for database see (configure database section)
dialect: sqlite3
connection: /opt/gotify/data/gotify.db
defaultuser: # on database creation, gotify creates an admin user
name: admin # the username of the default user
pass: admin # the password of the default user
passstrength: 10 # the bcrypt password strength (higher = better but also slower)
uploadedimagesdir: data/images # the directory for storing uploaded images
pluginsdir: data/plugins # the directory where plugin resides
registration: false # enable registrations
EOF
cat > ${HOME_NOTIFY}/systemd/gotify.service<<EOF
[Unit]
Description=Gotify Push Notification Server
Documentation=https://gotify.net/docs
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
StartLimitIntervalSec=14400
StartLimitBurst=10
[Service]
Restart=on-abnormal
WorkingDirectory=/opt/gotify
ExecStart=/opt/gotify/bin/gotify /opt/gotify/conf/config.yml
PrivateTmp=true
ProtectSystem=full
ReadWritePaths=/opt/gotify/data
ReadWriteDirectories=/opt/gotify/data
TimeoutStopSec=5s
[Install]
WantedBy=multi-user.target
EOF
ln -sf ${HOME_NOTIFY}/systemd/gotify.service /etc/systemd/system/
mkdir -p /etc/gotify
ln -sf ${HOME_NOTIFY}/conf/config.yml /etc/gotify
echo "export PATH='$PATH:/opt/gotify/bin'" > /etc/profile.d/gotify.sh
source /etc/profile.d/gotify.sh
if [ "${EVERSE_PROXY_ENABLE}" == "true" ]
then
check_apt=`command -v apt`
if [ $? == 0 ]
then
apt install nginx -y
else
yum install nginx -y
fi
cat > /etc/nginx/sites-enabled/gonotify.conf<<EOF
upstream gotify {
# Set the port to the one you are using in gotify
server 127.0.0.1:3111;
}
server {
# Here goes your domain / subdomain
#listen 443 ssl;
listen 80;
server_name `hostname`;
location / {
# We set up the reverse proxy
proxy_pass http://gotify;
proxy_http_version 1.1;
# Ensuring it can use websockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
proxy_redirect http:// $scheme://;
# The proxy must preserve the host because gotify verifies the host with the origin
# for WebSocket connections
proxy_set_header Host $http_host;
# These sets the timeout so that the websocket can stay alive
proxy_connect_timeout 1m;
proxy_send_timeout 1m;
proxy_read_timeout 1m;
}
}
EOF
fi
systemctl start gotify
systemctl status gotify
Execute
Bash scipt.sh