source: lliurex-zero-installers/trunk/fuentes/lliurex-zero-installer-analytics.zmds/lliurex-zero-installer-analytics.zmd @ 3455

Last change on this file since 3455 was 3455, checked in by mabarracus, 3 years ago

Fixed dialog strings cutted out

File size: 4.0 KB
Line 
1#!/bin/bash
2# Examples:
3# xgettext -o - -L Shell --keyword --keyword=GETTEXT lliurex-zero-installer-analytics.zmd
4# xgettext -o file.pot -L Shell --keyword --keyword=GETTEXT lliurex-zero-installer-analytics.zmd
5# LANG=es_ES.UTF-8 gettext -d lliurex-zero-installer-analytics -s "Enabled"
6# msginit -i file.pot -l es_ES.UTF-8
7# msgfmt -v es_ES.po -o es_ES.mo
8# cp es_ES.mo /usr/share/locale/es_ES/LC_MESSAGES/lliurex-zero-installer-analytics.mo
9#
10#
11# LANGUAGE SECTION
12#set -x
13
14zero-center add-pulsating-color lliurex-zero-installer-analytics
15
16export TEXTDOMAIN="lliurex-zero-installer-analytics"
17
18zenity --info --title="Lliurex-statistics" --text="$(gettext "Welcome to lliurex-statistics config tool\n")"
19
20# DETECTION SECTION
21
22ASK_QUESTION1="yes"
23ASK_QUESTION2="yes"
24
25#Subset detection from confirmator
26RUN_ON_LTSP="$(echo $LTSP_FATCLIENT)"
27if [ -n "${RUN_ON_LTSP}" ]; then
28    ASK_QUESTION1="no"
29    ASK_QUESTION2="no"
30    zenity --info --title="Lliurex-statistics" --text="$(gettext "This system isn't configurable\n")"
31    exit 0
32fi
33
34#RUN_AS_CLIENT=$(${LLIUREX_VERSION} |${GREP} -i -o client|uniq)
35RUN_AS_SERVER="$(lliurex-version |egrep -i -o server|uniq)"
36#RUN_AS_DESKTOP=""
37#if [ -z "${RUN_AS_CLIENT}" -a -z "${RUN_AS_SERVER}" ];then
38#    RUN_AS_DESKTOP="yes"
39#fi
40
41if [ -n "${RUN_AS_SERVER}" ];then
42    ASK_QUESTION1="yes"
43    ASK_QUESTION2="yes"
44else 
45#CLIENTS OR DESKTOPS
46    ASK_QUESTION1="yes"
47    ASK_QUESTION2="no"
48fi
49
50Q1_A="$(gettext "The anonymous statistics reporting agent is %s in this system. Do you want change this state?\n")"
51QUESTION1_B="$(gettext "What state must i use in this system?\n")"
52#echo Q1 $Q1
53VALUE_ME="$(cat /etc/lliurex-analytics/status|grep -i -o yes|uniq)"
54if [ -n "$VALUE_ME" ];then
55    STATUS_ME="$(gettext "enabled")"
56else
57    STATUS_ME="$(gettext "disabled")"
58fi
59
60QUESTION1_A="$(printf "$Q1_A" "$STATUS_ME")"
61#echo QUESTION1 $QUESTION1
62if [ "$ASK_QUESTION2" = "yes" ];then
63    Q2_A="$(gettext "The anonymous statistics reporting agent for classroom clients have %s status. Do you want to change reporting agent status?\n")"
64    QUESTION2_B="$(gettext "What state must i use for classroom clients?\n")"
65#    echo Q2 $Q2
66
67    # Example: n4d-client [ -u <usr> -p lliurex <pass> | -r ] -c NetinstallManager -m [ get_force_classroom_stats | set_force_classroom_stats -a [ 1 | 0 ] ]
68    CURRENT_VALUE="$(n4d-client -r -c NetinstallManager -m get_force_classroom_stats )"
69
70    STATUS_CLASS=""
71    if [ "x${CURRENT_VALUE}" = "x1" ]; then
72    #Enabled
73        STATUS_CLASS="$(gettext "enabled")"
74    else
75        if [ "x${CURRENT_VALUE}" = "x0" ]; then
76        #Disabled
77            STATUS_CLASS="$(gettext "disabled")"
78        else
79        #Unknown
80            STATUS_CLASS="$(gettext "unknown")"
81        fi
82    fi
83    QUESTION2_A="$(printf "$Q2_A" "$STATUS_CLASS")"
84#    echo QUESTION2 $QUESTION2
85fi
86
87
88# RUN QUESTIONS SECCTION
89zenity --question --text="$QUESTION1_A"  --ok-label="$(gettext "Yes")" --cancel-label="$(gettext "No")" > /dev/null 2>&1
90if [ $? -eq 0 ]; then
91    zenity --question --text="$QUESTION1_B"  --ok-label="$(gettext "Allow")" --cancel-label="$(gettext "Disallow")" > /dev/null 2>&1
92    if [ $? -eq 0 ]; then
93        #Enable local stats
94        echo yes > /etc/lliurex-analytics/status
95    else
96        #Disable local stats
97        echo no > /etc/lliurex-analytics/status
98    fi
99fi
100
101
102if [ "$ASK_QUESTION2" = "yes" ]; then
103    zenity --question --text="$QUESTION2_A"  --ok-label="$(gettext "Yes")" --cancel-label="$(gettext "No")" > /dev/null 2>&1
104    if [ $? -eq 0 ]; then
105        zenity --question --text="$QUESTION2_B"  --ok-label="$(gettext "Allow")" --cancel-label="$(gettext "Disallow")" > /dev/null 2>&1
106        if [ $? -eq 0 ]; then
107            #Enable classroom stats
108            RES="$(n4d-client -r -c NetinstallManager -m set_force_classroom_stats -a 1)"
109        else
110            #Disable classroom stats
111            RES="$(n4d-client -r -c NetinstallManager -m set_force_classroom_stats -a 0)"
112        fi
113    fi
114fi
115zero-center set-configured lliurex-zero-installer-analytics
116zero-center remove-pulsating-color lliurex-zero-installer-analytics
117exit 0
Note: See TracBrowser for help on using the repository browser.