slitaz-tools rev 1011
Add sdt SliTaz Distro Tracker
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Feb 11 23:41:23 2017 +0100 (2017-02-11) |
parents | 781f12e0836c |
children | 2e8f6a09785c |
files | sdt/Makefile sdt/README sdt/sdt |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/sdt/Makefile Sat Feb 11 23:41:23 2017 +0100 1.3 @@ -0,0 +1,9 @@ 1.4 +# Makefile for SDT - SliTaz Distro Tracker Tools 1.5 +# 1.6 +DESTDIR?= 1.7 +PREFIX?=/usr 1.8 + 1.9 +install: 1.10 + install -m 0755 -d $(DESTDIR)$(PREFIX)/bin 1.11 + install -m 0755 sdt $(DESTDIR)$(PREFIX)/bin 1.12 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/sdt/README Sat Feb 11 23:41:23 2017 +0100 2.3 @@ -0,0 +1,11 @@ 2.4 +SDT 2.5 +================================================================================ 2.6 + 2.7 +SDT stand for SliTaz Distro Tracker. A small set of tools to track and 2.8 +build a DB of SliTaz live and insall systems. 2.9 + 2.10 +sdt: is the cmdline client 2.11 +Web interface is on scn.slitaz.org/?sdt 2.12 + 2.13 +The CGI web interface work as a TinyCM plugin, code can be found in 2.14 +slitaz-forge/scn HG repository.
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/sdt/sdt Sat Feb 11 23:41:23 2017 +0100 3.3 @@ -0,0 +1,80 @@ 3.4 +#!/bin/sh 3.5 +# 3.6 +# SDT - SliTaz Distro Tracker Cmdline client 3.7 +# 3.8 +# (C) SliTaz GNU/Linux 2017 - BSD License 3.9 +# 3.10 +. /lib/libtaz.sh 3.11 + 3.12 +version="0.1" 3.13 +url="http://scn.slitaz.org/" 3.14 +tmp="/tmp/$(basename $0).msg" 3.15 +date="$(date +%Y%m%d)" 3.16 + 3.17 +get_geoloc() { 3.18 + # freegeoip.net/{format}/{ip_or_hostname} 3.19 + # Exemple: wget freegeoip.net/csv/${ip} -O /tmp/geoloc 3.20 + wget -q "${url}?sdt=geoloc" -O ${tmp} 3.21 + ip=$(cat ${tmp}) && rm ${tmp} 3.22 + wget -q freegeoip.net/csv/${ip} -O /tmp/geoloc 3.23 + country=$(cat /tmp/geoloc | cut -d ',' -f 3 ) 3.24 + echo "$country" && rm -f /tmp/geoloc 3.25 +} 3.26 + 3.27 +get_mode() { 3.28 + if grep -q "root=/dev/null" /proc/cmdline; then 3.29 + echo "live" 3.30 + else 3.31 + echo "install" 3.32 + fi 3.33 +} 3.34 + 3.35 +case "$1" in 3.36 + get-stats) 3.37 + # Get some info from the DB 3.38 + newline 3.39 + boldify "SDT Stats" 3.40 + separator 3.41 + if wget -q -T 5 --spider ${url}; then 3.42 + echo "Tracker in online..." 3.43 + wget -q "${url}?sdt=raw" -O ${tmp} && cat ${tmp} && rm ${tmp} 3.44 + else 3.45 + echo "Tracker in unreachable..." 3.46 + fi 3.47 + separator && newline ;; 3.48 + send) 3.49 + # Send stats to online DB 3.50 + user="$2" 3.51 + [ "$user" ] || user="anonymous" 3.52 + country=$(get_geoloc) 3.53 + release=$(cat /etc/slitaz-release) 3.54 + kernel=$(uname -r) 3.55 + mode=$(get_mode) 3.56 + cat << EOT 3.57 + 3.58 +$(boldify "Informations sent to SliTaz Distro Tracker") 3.59 +$(separator) 3.60 +User : ${user} 3.61 +Country : ${country} 3.62 +Release : SliTaz ${release} 3.63 +Kernel : ${kernel} 3.64 +Running : ${mode} 3.65 +EOT 3.66 + separator && newline 3.67 + echo "Send these data to SliTaz Distro Tracker ? " 3.68 + echo -n "Press 'c' then ENTER to continue or any other key to quit: " 3.69 + read anser && newline 3.70 + if [ "$anser" != "c" ]; then 3.71 + exit 0 3.72 + fi 3.73 + echo "Sending data to: $url" && newline 3.74 + wget -q --user-agent "SliTaz/SDT" \ 3.75 +"${url}?sdt=add&user=${user}&country=${country}&release=${release}&kernel=${kernel}&mode=${mode}" \ 3.76 + -O ${tmp} && cat ${tmp} && rm ${tmp} 3.77 + ;; 3.78 + *) 3.79 + newline 3.80 + echo "$(boldify 'Usage:') $(basename $0) [get-stats|send] [username]" 3.81 + newline ;; 3.82 +esac 3.83 +exit 0