initial migration commit
This commit is contained in:
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
if [ $1 ]
|
||||
then
|
||||
systemctl stop nginx
|
||||
/root/certbot/certbot-auto certonly --standalone --preferred-challenges http -d $1
|
||||
systemctl start nginx
|
||||
else
|
||||
echo "Usage: create_new_cert.sh <newdomain.fqdn>"
|
||||
fi
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
echo "INPUT Chain"
|
||||
iptables -vnL INPUT | grep "dpt:443"
|
||||
iptables -vnL INPUT | grep "dpt:8448"
|
||||
iptables -vnL INPUT | grep "LOGGING"
|
||||
|
||||
echo -e "\nOUTPUT Chain"
|
||||
iptables -vnL OUTPUT | grep "dpt:443"
|
||||
iptables -vnL OUTPUT | grep "dpt:8448"
|
||||
|
||||
echo -e "\nBeancounters"
|
||||
cat /proc/user_beancounters | grep tcpsndbuf
|
||||
cat /proc/user_beancounters | grep tcprcvbuf
|
||||
cat /proc/user_beancounters | grep shmpages
|
||||
|
||||
echo -e "\nIPtables Log"
|
||||
dmesg
|
||||
|
||||
#echo -e "\n\nSearx Log"
|
||||
#tail -n10 /var/log/nginx/002-searx-access.log
|
||||
|
||||
Executable
+145
@@ -0,0 +1,145 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## Copyright (C) 2019 Michael Neese
|
||||
##
|
||||
## This program is free software: you can redistribute it and/or modify it
|
||||
## under the terms of the GNU General Public License as published
|
||||
## by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
## without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
## See the GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with this program.
|
||||
## If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
## This script sends a message to a matrix room <https://matrix.org>.
|
||||
## Requires a matrix synapse (https://github.com/matrix-org/synapse) server as endpoint and jq on the system which runs the script.
|
||||
## Usable for e.g. cronjobs, nagios notifications or ci pipelines.
|
||||
|
||||
AUTHOR="Michael Neese <madic@geekbundle.org>"
|
||||
MATRIX_USER_TEMP=""
|
||||
MATRIX_PASS_TEMP=""
|
||||
MATRIX_SERVER_TEMP=""
|
||||
MATRIX_ROOM_ID_TEMP=""
|
||||
MATRIX_ACCESS_TOKEN_TEMP=""
|
||||
# Allowed values: 0 and 1
|
||||
DEBUG=${DEBUG:-"0"}
|
||||
|
||||
# Check if jq is installed
|
||||
if ! [ -x "$(command -v jq)" ]; then
|
||||
echo 'Error: jq is not installed.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
USAGE() {
|
||||
echo "Usage: COMMAND | ${0##*/} [OPTION]
|
||||
Send a (multiline) message to a matrix room.
|
||||
This script expects data to be piped in on STDIN.
|
||||
Options:
|
||||
-u Matrix User Name
|
||||
-p Matrix User Password
|
||||
-a Matrix Access Token
|
||||
-s Matrix Server FQDN
|
||||
-r Matrix RoomID
|
||||
-f Optional configuration file
|
||||
-h Show help message
|
||||
You can either provide an access token or username / password.
|
||||
If no access token is provided, this script will get one for you from the server.
|
||||
But keep in mind, that every time this script runs without an access token, a new access token is created and fills up your device list.
|
||||
With to many devices in your device list, there is a potential getting blacklisted.
|
||||
The recommended way is to provide an access token.
|
||||
Getting an access token from the server:
|
||||
curl -s -X POST -d '{ \"type\":\"m.login.password\", \"user\":\"\$MATRIX_USER\", \"password\":\"\$MATRIX_PASS\" }' \"https://\$MATRIX_SERVER/_matrix/client/r0/login\" | jq -r '.access_token'
|
||||
Before you can send a message to a room, the user sending the message already needs to have joined it.
|
||||
Examples:
|
||||
echo \"Testmessage 1\" | ${0##*/} -f /etc/${0##*/}.conf
|
||||
echo \"Testmessage 2\" | ${0##*/} -f /etc/${0##*/}.conf -r \!QtykxKocfZaZOUrTwp:matrix.org
|
||||
Please keep an eye on the format of the RoomID!
|
||||
Configuration file:
|
||||
The configuration file can contain the following values.
|
||||
MATRIX_USER=TestUser
|
||||
MATRIX_PASS=TestPassword
|
||||
MATRIX_ACCESS_TOKEN=MD..blah
|
||||
MATRIX_SERVER=matrix.org
|
||||
# RoomID from the #matrix:matrix.org Channel
|
||||
MATRIX_ROOM_ID=\"!QtykxKocfZaZOUrTwp:matrix.org\"
|
||||
These values can be overriden by command line parameters.
|
||||
Cron Job:
|
||||
It's also possible to use this script to send the output of a cronjob to a matrix room.
|
||||
Example:
|
||||
SHELL=/bin/bash
|
||||
0 4 * * * root /usr/local/sbin/random_script | ${0##*/} -f /etc/${0##*/}.conf
|
||||
0 5 * * * OUTPUT=\"# \$(hostname -f) - random_script\" && OUTPUT=\"\$OUTPUT\n$(random_script)\" && echo -e \"\$OUTPUT\" | ${0##*/} -f /etc/${0##*/}.conf
|
||||
The last example allows appending e.g. the fqdn of the server and custom text to a message.
|
||||
With this approach it's possible to send the same message from different servers to the same room and still be able to keep track from which server the message originates.
|
||||
Report bugs to: $AUTHOR
|
||||
Homepage: <https://www.geekbundle.org>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
while getopts ":f:u:a:p:s:r:h" opt; do
|
||||
case "$opt" in
|
||||
f)
|
||||
CONFIG_FILE="$OPTARG"
|
||||
;;
|
||||
u)
|
||||
MATRIX_USER_TEMP="$OPTARG"
|
||||
;;
|
||||
p)
|
||||
MATRIX_PASS_TEMP="$OPTARG"
|
||||
;;
|
||||
a)
|
||||
MATRIX_ACCESS_TOKEN_TEMP="$OPTARG"
|
||||
;;
|
||||
s)
|
||||
MATRIX_SERVER_TEMP="$OPTARG"
|
||||
;;
|
||||
r)
|
||||
MATRIX_ROOM_ID_TEMP="$OPTARG"
|
||||
;;
|
||||
h)
|
||||
USAGE
|
||||
;;
|
||||
*)
|
||||
USAGE
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Test if stdin is not empty
|
||||
[ -t 0 ] && USAGE
|
||||
|
||||
# Read parameters from config file
|
||||
if [ -f "$CONFIG_FILE" ]; then source "$CONFIG_FILE"; fi
|
||||
|
||||
# Override config file values with the values from the command line
|
||||
if [ -n "$MATRIX_USER_TEMP" ]; then MATRIX_USER="$MATRIX_USER_TEMP"; fi
|
||||
if [ -n "$MATRIX_PASS_TEMP" ]; then MATRIX_PASS="$MATRIX_PASS_TEMP"; fi
|
||||
if [ -n "$MATRIX_ACCESS_TOKEN_TEMP" ]; then MATRIX_ACCESS_TOKEN="$MATRIX_ACCESS_TOKEN_TEMP"; fi
|
||||
if [ -n "$MATRIX_SERVER_TEMP" ]; then MATRIX_SERVER="$MATRIX_SERVER_TEMP"; fi
|
||||
if [ -n "$MATRIX_ROOM_ID_TEMP" ]; then MATRIX_ROOM_ID="$MATRIX_ROOM_ID_TEMP"; fi
|
||||
|
||||
# Test if all required variables are not empty
|
||||
if [ -z "$MATRIX_USER" ] || [ -z "$MATRIX_PASS" ] || [ -z "$MATRIX_SERVER" ] || [ -z "$MATRIX_ROOM_ID" ]; then USAGE; fi
|
||||
|
||||
# Get Matrix Access Token if none provided
|
||||
if [ -z "$MATRIX_ACCESS_TOKEN" ]; then
|
||||
MATRIX_ACCESS_TOKEN=$(curl -s -X POST -d "{ \"type\":\"m.login.password\", \"user\":\"$MATRIX_USER\", \"password\":\"$MATRIX_PASS\" }" "https://$MATRIX_SERVER/_matrix/client/r0/login" | jq -r '.access_token')
|
||||
fi
|
||||
|
||||
# Some debug code
|
||||
if [ "$DEBUG" -eq 1 ]; then
|
||||
echo "curl -s -X POST -d \"{ \"type\":\"m.login.password\", \"user\":\"$MATRIX_USER\", \"password\":\"$MATRIX_PASS\" }\" \"https://$MATRIX_SERVER/_matrix/client/r0/login\" | jq -r '.access_token'"
|
||||
echo -e "\nMatrix Access Token: $MATRIX_ACCESS_TOKEN"
|
||||
fi
|
||||
|
||||
# Send Message and output errors on DEBUG=1
|
||||
if [ "$DEBUG" -eq 1 ]; then
|
||||
curl -X POST -d "$(jq -Rs --arg msgtype m.text '{$msgtype, body:.}')" "https://$MATRIX_SERVER/_matrix/client/r0/rooms/$MATRIX_ROOM_ID/send/m.room.message?access_token=$MATRIX_ACCESS_TOKEN"
|
||||
fi
|
||||
|
||||
# Send message without any output if DEBUG < 1
|
||||
if [ "$DEBUG" -lt 1 ]; then
|
||||
curl -s -o /dev/null -X POST -d "$(jq -Rs --arg msgtype m.text '{$msgtype, body:.}')" "https://$MATRIX_SERVER/_matrix/client/r0/rooms/$MATRIX_ROOM_ID/send/m.room.message?access_token=$MATRIX_ACCESS_TOKEN"
|
||||
fi
|
||||
@@ -0,0 +1,86 @@
|
||||
# sendtomatrix
|
||||
|
||||
Linux shell script to send a (multiline) message to a [matrix room](https://matrix.org) hosted on a [synapse server](https://github.com/matrix-org/synapse).
|
||||
|
||||
Usable for e.g. cronjobs, nagios notifications or ci pipelines.
|
||||
|
||||
## Usage
|
||||
|
||||
This script expects data to be piped in on STDIN.
|
||||
|
||||
```bash
|
||||
COMMAND | sendtomatrix [OPTION]
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
* -u Matrix User Name
|
||||
* -p Matrix User Password
|
||||
* -a Matrix Access Token
|
||||
* -s Matrix Server FQDN
|
||||
* -r Matrix RoomID
|
||||
* -f Optional configuration file
|
||||
* -h Show help message
|
||||
|
||||
You can either provide an access token or username / password.
|
||||
If no access token is provided, this script will get one for you from the server.
|
||||
|
||||
But keep in mind, that every time this script runs without an access token, a new access token is created and fills up your device list.
|
||||
With to many devices in your device list, there is a potential getting blacklisted.
|
||||
|
||||
The recommended way is to provide an access token.
|
||||
|
||||
### Getting an access token from the server
|
||||
|
||||
```bash
|
||||
curl -s -X POST -d '{ "type":"m.login.password", "user":"$MATRIX_USER", "password":"$MATRIX_PASS" }' "https://$MATRIX_SERVER/_matrix/client/r0/login" | jq -r '.access_token'
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
echo "Testmessage 1" | sendtomatrix -f /etc/sendtomatrix.conf
|
||||
echo "Testmessage 2" | sendtomatrix -f /etc/sendtomatrix.conf -r "\!QtykxKocfZaZOUrTwp:matrix.org"
|
||||
```
|
||||
|
||||
Please keep an eye on the format of the RoomID!
|
||||
|
||||
## Requirements
|
||||
|
||||
* [Synapse server](https://github.com/matrix-org/synapse) as API endpoint
|
||||
* jq on the system which runs the script
|
||||
* Before you can send a message to a room, the user sending the message already needs to have joined it
|
||||
|
||||
## Configuration file
|
||||
|
||||
The configuration file can contain the following values:
|
||||
|
||||
```bash
|
||||
MATRIX_USER=TestUser
|
||||
MATRIX_PASS=TestPassword
|
||||
MATRIX_ACCESS_TOKEN=MD..blah
|
||||
MATRIX_SERVER=matrix.org
|
||||
# RoomID from the #matrix:matrix.org Channel
|
||||
MATRIX_ROOM_ID="!QtykxKocfZaZOUrTwp:matrix.org"
|
||||
```
|
||||
|
||||
These values can be overriden by command line parameters.
|
||||
|
||||
## Cron Job
|
||||
|
||||
It's also possible to use this script to send the output of a cronjob to a matrix room.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
SHELL=/bin/bash
|
||||
0 4 * * * root /usr/local/sbin/random_script | sendtomatrix -f /etc/sendtomatrix.conf
|
||||
0 5 * * * OUTPUT="# $(hostname -f) - random_script" && OUTPUT="$OUTPUT\n" && echo -e "$OUTPUT" | sendtomatrix -f /etc/sendtomatrix.conf
|
||||
```
|
||||
|
||||
The last example allows appending e.g. the fqdn of the server and custom text to a message.
|
||||
|
||||
With this approach it's possible to send the same message from different servers to the same room and still be able to keep track from which server the message originates.
|
||||
|
||||
# Original github-repo
|
||||
https://github.com/Madic-/Scripts/tree/master/Linux/sendtomatrix
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
####################################################################
|
||||
##
|
||||
## script to automaticaly update RIOT-web
|
||||
##
|
||||
####################################################################
|
||||
|
||||
# change working dir
|
||||
cd /var/www/vhosts/solusar.de/subdomains/
|
||||
|
||||
# check if there is an active installation
|
||||
if [ -d riot ]
|
||||
then
|
||||
# find old version number
|
||||
oldver=`cat riot/version`
|
||||
echo "Installed version is $oldver"
|
||||
read -p "Need to update (Y/n)? " answer
|
||||
else
|
||||
echo "There is no active RIOT-web installation! Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$answer" in
|
||||
Y|y|"")
|
||||
# ask for the new version number to install
|
||||
read -p "Upgrade to which version (format x.x.x[-rcX])? " ver
|
||||
if [ -n $ver ]
|
||||
then
|
||||
# if theres an old version archive...
|
||||
if [ -f riot-v$oldver.tar.gz ]
|
||||
then
|
||||
echo "Found old version archive. Removing..."
|
||||
rm riot-v$oldver.tar.gz
|
||||
fi
|
||||
|
||||
# download new version archive if nessesary
|
||||
if [ ! -f riot-v$ver.tar.gz ]
|
||||
then
|
||||
echo "Getting new version..."
|
||||
#wget https://github.com/vector-im/riot-web/releases/download/v$ver/riot-v$ver.tar.gz
|
||||
wget https://github.com/vector-im/riot-web/releases/download/v$ver/riot-v$ver.tar.gz
|
||||
fi
|
||||
|
||||
if [ -f riot-v$ver.tar.gz ]
|
||||
then
|
||||
echo "Unpacking..."
|
||||
tar xzf riot-v$ver.tar.gz
|
||||
|
||||
# if there's an old version...
|
||||
if [ -d riot.old ]
|
||||
then
|
||||
# delete the old version
|
||||
rm -r riot.old
|
||||
fi
|
||||
mv riot riot.old
|
||||
mv riot-v$ver riot
|
||||
echo "Copying config..."
|
||||
cp riot.old/config.riot.solusar.de.json riot/
|
||||
cp riot.old/config.json riot/
|
||||
echo "Changing permissions..."
|
||||
chown -R www-data:www-data riot/
|
||||
echo "Done."
|
||||
else
|
||||
echo "Could not download new version. Check URL or version number!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
N|n)
|
||||
echo "Exiting..."
|
||||
;;
|
||||
*)
|
||||
echo "Unknown action, exiting..."
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user