Commit eb49fb17 authored by Alex's avatar Alex

Readme hinzugefügt mit installationsanleitung.

parent 65f3c3eb
# Raspberry Pi SMS Gateway mit einem SIM800L Modul
# Quellen
* https://playsms.org/2018/06/26/playsms-1-4-2-on-ubuntu-18-04/
* https://playsms.org/2018/08/01/again-timezone-setup/
* https://www.howtoforge.com/tutorial/how-to-install-raspberry-pi-sms-server/
* http://smstools3.kekekasvi.com/index.php?p=compiling
# setup
## Pakete installieren
```bash
apt -y install nginx php-fpm php-cli php-mysql php-gd php-imap php-curl php-xml php-mbstring mariadb-server git
```
## Anpassung nginx Config
```bash
cd /etc/nginx/sites-available
cp default default-custom
cd ../sites-enabled
rm default && ln -s /etc/nginx/sites-available/default-custom
```
default-custom Konfig:
```
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/playsms;
index index.php;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
```
Konfig überprüfen mit `nginx -t` und Webserver neustarten:
`systemctl restart nginx.service`
### PHP Zeitzone
Edititiere `/etc/php/7.0/fpm/php.ini` und `/etc/php/7.0/cli/php.ini` , suche nach `date.timezone` und setze es auf `Europe/Berlin` .
PHP-FPM Dienst neustarten:
`systemctl restart php7.0-fpm.service`
### Datenbank
Datenbank anlegen mit
`mysqladmin create playsms`
In mysql Promt wechseln mit `mysql` und playsms Benutzer anlegen.
```sql
CREATE USER 'playsms'@'localhost' IDENTIFIED BY 'changethislater';
GRANT ALL PRIVILEGES ON playsms.* TO 'playsms'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit
```
### playsms installieren
```bash
cd /var/www/
rm -R html/
mkdir playsms
git clone https://github.com/antonraharja/playSMS.git playSMSsrc
cd playSMSsrc
git checkout 1.4.2
cp install.conf.dist install.conf
```
install.conf bearbeiten und folgende Variablen setzen:
* DBUSER="playsms"
* DBPASS="changethislater"
* PATHWEB="/var/www/playsms"
* PATHLIB="/var/local/lib/playsms"
* PATHCONF="/etc/playsms"
Danach `./install-playsms.sh` ausführen.
Konfiguration überprüfen mit `playsmsd /etc/playsms/playsmsd.conf check`
Login mit `admin` und `admin`.
## sms tools 3
### Pakete installieren
```bash
apt install build-essential manpages-dev
```
### download und compile
Downloadlink: http://smstools3.kekekasvi.com/index.php?p=packages
```bash
cd /usr/local/src
wget http://smstools3.kekekasvi.com/packages/smstools3-3.1.21.tar.gz
tar -xzvf smstools3-3.1.21.tar.gz
cd smstools3
make
make install
```
Erforderliche Ordner erstellen:
```bash
mkdir -p /var/log/sms/stats
mkdir -p /var/spool/sms/{checked,failed,incoming,outgoing,sent}
mkdir /var/spool/sms/modem1
chown www-data:www-data -R /var/spool/sms
chmod 777 -R /var/spool/sms
```
Orginal Konfiguration verschieben und die Beispielkonfiguration von playsms installieren.
```bash
mv /etc/smsd.conf /etc/smsd.conf.orig
nano /etc/smsd.conf
```
Inhalt der `smsd.conf`:
```
# Global configuration
devices = modem1
loglevel = 5
# logfiles
stats = /var/log/sms/stats
logfile = /var/log/sms/smsd.log
# Default queue directory = /var/spool/sms
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
incoming = /var/spool/sms/incoming
sent = /var/spool/sms/sent
# do not set report folder, let status report files saved in incoming
#report = /var/spool/sms/report
delaytime = 2
errorsleeptime = 10
blocktime = 180
autosplit = 3
#receive_before_send = yes
# Queue configurations
[queues]
modem1 = /var/spool/sms/modem1
# Modem configurations
# Modem name: modem1
# Modem type: Wavecom USB
[modem1]
#init = AT+CNMI=2,2,0,1,0;+CMEE=1
device = /dev/serial0
baudrate = 115200
incoming = yes
report = yes
queues = modem1
```
## Fail2ban
Installieren mit `apt install fail2ban`
```bash
nano /etc/fail2ban/filter.d/playsms.conf
nano /etc/fail2ban/jail.local
```
Inhalt der playsms.conf
```
[Definition]
# beispiel
# 127.0.0.1 localhost:8182 2018-10-11 10:21:03 PID5bbf07eedca1c - L2 auth_validate_login # invalid login u:admin uid:1 ip:127.0.0.1
#failregex = L2 login # invalid login [ut]:.* ip:<HOST>
failregex = L2 auth_validate_login # invalid login [ut]:.* ip:<HOST>
ignoreregex =
```
Inhalt der jail.local
```
#############################
[playsms]
enabled = true
port = 80,443
protocol = tcp
filter = playsms
logpath = /var/log/playsms/playsms.log
############################
```
Fail2ban restart `systemctl restart fail2ban.service`
## Systemd Dateien
/etc/systemd/system/playsms.service
```
[Unit]
Description=PlaySMS
After=mariadb.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/playsmsd /etc/playsms/playsmsd.conf start
ExecStop=/usr/local/bin/playsmsd /etc/playsms/playsmsd.conf stop
[Install]
WantedBy=multi-user.target
```
/etc/systemd/system/smsd.service
```
[Unit]
Description=SMS Server Tools 3
After=syslog.target
[Service]
ExecStart=/usr/local/bin/smsd -c /etc/smsd.conf -s
Restart=always
PermissionsStartOnly=true
[Install]
WantedBy=multi-user.target
```
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment