-
Notifications
You must be signed in to change notification settings - Fork 1
/
GAauto.sh
executable file
·75 lines (67 loc) · 1.91 KB
/
GAauto.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
# Author: Lilian BESSON
# Email: Lilian.BESSON[AT]ens-cachan[DOT]fr
# Website: https://bitbucket.org/lbesson/bin/src/master/GAauto.sh
# Date: 26-04-2016
#
# A small script to add a one-pixel beacon image to every HTML files in a directory.
# Requires: AddGA.sh (http://perso.crans.org/besson/bin/AddGA.sh)
#
clear
PWD="$(pwd)"
# Put here the default values for these variables
# h: domain name (mysite.com for instance)
# c: path corresponding to root of the website (/var/web/ or /home/superman/Public/ for instance
# key: your Google Analytics key (UA-461468-3 for instance)
#
h="localhost"
c="/"
key="UA-38514290-1"
# You can make a case analysis here, to be able the run the same script on different servers.
case "$HOSTNAME" in
*jarvis*)
h="jarvis"
c="${PWD#/home/lilian/}"
c="${c#Public/}"
case "${c}" in
cs* )
key="UA-38514290-13"
;;
ma* )
key="UA-38514290-12"
;;
esac
;;
*ssh*)
h="www.dptinfo.ens-cachan.fr/~lbesson/"
key="UA-38514290-2"
c="${PWD#/import/lbesson/}"
c="${c#public_html/}"
;;
*zamok*)
h="perso.crans.org/besson/"
key="UA-38514290-1"
c="${PWD#/home/b/besson/}"
c="${c#www/}"
case "${c}" in
cs* )
key="UA-38514290-13"
;;
ma* )
key="UA-38514290-12"
;;
esac
;;
esac
# Starting.
echo -e "${yellow}.: Lilian Besson presents :."
echo -e "${cyan}Adding Google Analytics beacon every where, v0.1${reset}"
echo -e "Working on the domain '${red}$h${white}' with default path '${red}$c${white}'."
echo -e "Using the Google Analytics key '${green}$key${white}'."
n="$(find . -type f -iname '*'.htm'*' | wc -l)"
echo -e "There is '${red}$n${white}' readable file(s) in the current dir, is that ok ? (it might take some time...)"
read -e -p "Continue ? [Ctrl+C to cancel now or after]"
find . -type f -iname '*'.htm'*' -exec AddGA.sh "$@" "${key}" "${c}" {} \; \
| tee /tmp/GAauto.log \
&& echo -e "DONE :)" \
|| echo -e "ERROR :("