diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000000000000000000000000000000000000..9744f550af9a03fadc99b28797dede93a6c5bc54 --- /dev/null +++ b/Readme.md @@ -0,0 +1,24 @@ +# Script utils + +## Healthreport + +## Dependencies + +systemd +aptitude +debian-goodies +ufw +cpufreq-utils +lm-sensors +pandoc + + +The following scripts must be in the same directory + + getip.sh + +## Install + +Add the crontab entry + + 0 7 * * 1 /path/to/healthReport.sh -m "Weekly health report" 2> /dev/null diff --git a/getip.sh b/getip.sh new file mode 100755 index 0000000000000000000000000000000000000000..32db8eb72688a89591622bd92556641c45b9ee72 --- /dev/null +++ b/getip.sh @@ -0,0 +1,40 @@ +#!/bin/bash +isIP() +{ + ret=1 + ip=$1 + if [[ $ip=~^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] + then + OIFS=$IFS + IFS='.' + ip=($1) + IFS=$OIFS + [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] + ret=$? + + fi + return $ret +} +#Parse IP from sfr/orange box +myip=$(curl $(/sbin/route | grep default | /usr/bin/awk {'print $2'}) \ + | grep "Adresse IP" -A 1 | /usr/bin/tail -n 1 |\ + sed -e "s/.*>[^0-9]*\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\)[^0-9]*<.*/\1/g") +if isIP $myip +then + echo "External IP is : $myip" + exit 0 +fi +#Old bad method using hosts, usable if the first method fail +Hosts=("icanhazip.com" "ident.me" "ipecho.net/plain" \ + "whatismyip.akamai.com" "tnx.nl/ip" "myip.dnsomatic.com" \ + "ip.appspot.com" "ip.telize.com" "curlmyip.com" "ifconfig.me" ) +for h in ${Hosts[@]} +do + myip=$(curl -s $h) + if isIP $myip + then + echo "External IP is : $myip" + exit 0 + fi +done + diff --git a/healthReport.sh b/healthReport.sh index 9e3f939d875048048ded0a018012d365ef06905f..0dd5ba6204f52695a661e17c4113d4535aa08337 100755 --- a/healthReport.sh +++ b/healthReport.sh @@ -16,8 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -sendername="Tetras Libre" -recipient="$sendername <admin@tetras-libre.fr>" +sendername="root@`hostname`" +recipient="root" level=info date="$(date +%y%m%d_%H%M)" archiveFile="HealthReport-$date.tar.xz"