2022-04-27 00:02:50 +02:00
|
|
|
# Bash Scripts collection
|
|
|
|
|
2023-12-07 23:22:39 +01:00
|
|
|
TODO: Need install packages for each script
|
|
|
|
|
2023-07-25 17:20:02 +02:00
|
|
|
## Permanent enviroment variables in ~/.profile
|
2023-01-27 15:36:13 +01:00
|
|
|
|
2023-07-25 17:20:02 +02:00
|
|
|
Append file `~/.profile` with this variables:
|
|
|
|
|
|
|
|
```
|
|
|
|
# E7 Scripts
|
|
|
|
# ClamAV scan script
|
|
|
|
export E7S_CLAM_LOGPATH="/path/to/logs/"
|
|
|
|
# Multiple folders separate by space
|
|
|
|
export E7S_CLAM_DIRSTOSCAN="/path/to/target/"
|
|
|
|
# Global script variables
|
|
|
|
export E7S_GOTIFY_SERVER_URL="https://push.example.com"
|
|
|
|
export E7S_LOGS_PRESERVE_DAYS=30
|
|
|
|
export ES7_LOGS_SERVER_SSH="server.example.com"
|
|
|
|
export ES7_LOGS_PATH="/path/to/web/root/"
|
|
|
|
export ES7_LOGS_URL="https://logs.example.com"
|
|
|
|
```
|
|
|
|
|
|
|
|
## Scripts
|
|
|
|
|
|
|
|
### utils/gotifypush.sh
|
2022-04-27 00:02:50 +02:00
|
|
|
|
|
|
|
Send markdown notifications to gotify channel throught curl
|
|
|
|
|
2022-09-29 12:27:20 +02:00
|
|
|
* Usage: `./gotifypush.sh <title> <message> <priority> <token> <clickurl>`
|
|
|
|
|
2023-07-25 17:20:02 +02:00
|
|
|
### utils/logger.sh
|
|
|
|
|
|
|
|
Save logs into remote server and publish it into web server
|
|
|
|
|
|
|
|
* Usage: `./logger.sh <logfile> <relativepath>`
|
|
|
|
|
|
|
|
### scan_chk.sh
|
2022-09-29 12:27:20 +02:00
|
|
|
|
|
|
|
Scan rootkits into system with chkrootkit
|
|
|
|
|
|
|
|
* Usage: `./scan_chk.sh`
|
|
|
|
|
2023-07-25 17:20:02 +02:00
|
|
|
### scan_rkh.sh
|
2022-09-29 12:27:20 +02:00
|
|
|
|
|
|
|
Scan rootkits into system with rkhunter
|
|
|
|
|
|
|
|
* Usage: `./scan_rkh.sh`
|
|
|
|
|
2023-07-25 17:20:02 +02:00
|
|
|
### scan_clam.sh
|
2022-09-29 12:27:20 +02:00
|
|
|
|
|
|
|
Scan virus and malware into system with clamav
|
|
|
|
|
|
|
|
* Usage: `./scan_clam.sh`
|
2023-12-07 23:22:39 +01:00
|
|
|
|
|
|
|
### updates_notifier.sh
|
|
|
|
|
|
|
|
TODO!
|
|
|
|
|
|
|
|
## Some tips
|
|
|
|
|
|
|
|
* https://www.appsloveworld.com/bash/100/6/how-have-both-local-and-remote-variable-inside-an-ssh-command
|
|
|
|
* https://stackoverflow.com/questions/27932694/shell-script-ssh-server-eof (script detect expire users)
|
|
|
|
* use xargs: https://www.baeldung.com/linux/xargs-multiple-arguments
|
|
|
|
* load env vars in cron: https://www.baeldung.com/linux/load-env-variables-in-cron-job
|
|
|
|
* crontab need path sometimes: https://askubuntu.com/questions/117978/script-doesnt-run-via-crontab-but-works-fine-standalone
|
|
|
|
* errors and best practices: https://tecadmin.net/resolved-unary-operator-expected-error-in-bash/
|