~ubuntu-branches/ubuntu/trusty/prey/trusty

« back to all changes in this revision

Viewing changes to .pc/02-config_file_path.patch/prey.sh

  • Committer: Package Import Robot
  • Author(s): Facundo Guerrero
  • Date: 2014-01-07 11:00:30 UTC
  • mfrom: (9.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140107110030-19fbnzwhf4yglof4
Tags: 0.6.2-1
* New maintainer (Closes: #726354).
* ACK 0.5.3-7.1 NMU by ChristianPerrier (Thanks!).
* New upstream release.
* Refresh debian/patches/01-disable_auto_updates.patch patch.
* Refresh debian/patches/02-config_file_path.patch.
* Refresh debian/patches/03-prey_configurator.patch.
* Refresh debian/patches/04-crontab.patch.
* Refresh debian/patches/05-modules_handling.patch.
* Remove  debian/patches/10-fix_quoting.patch.
* Add GTK application to configure Prey.
* Update download url in debian/watch.
* Updated Standards Version to 3.9.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
####################################################################
3
 
# Prey Client - by Tomas Pollak (bootlog.org)
4
 
# URL: http://preyproject.com
 
3
# Prey Bash Client - (c) Fork Ltd.
 
4
# http://preyproject.com
5
5
# License: GPLv3
6
6
####################################################################
7
7
 
8
8
PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH
9
 
readonly base_path=`dirname "$0"`
 
9
readonly base_path=$(dirname "$0")
10
10
 
11
11
####################################################################
12
12
# base files inclusion
24
24
#       exit 1
25
25
# fi
26
26
 
27
 
log "${cyan}$STRING_START ### $(uname -a)${color_end}\n"
 
27
log "\n${cyan} ## $STRING_START\n ## $(uname -a)\n ## $(date)${color_end}\n"
28
28
 
29
29
####################################################################
30
30
# lets check if we're actually connected
42
42
        # ok, lets check again, after waiting a bit
43
43
        sleep 5
44
44
        check_net_status
 
45
 
45
46
        if [ $connected == 0 ]; then
 
47
 
46
48
                log "$STRING_NO_CONNECT_TO_WIFI"
47
49
                if [ -f "$last_response" ]; then # offline actions were enabled
 
50
 
48
51
                        log ' -- Offline actions enabled!'
49
52
                        offline_mode=1
50
53
                        get_last_response
 
54
                        process_module_config
 
55
 
51
56
                else
52
57
                        exit 1
53
58
                fi
 
59
 
54
60
        fi
55
61
fi
56
62
 
78
84
 
79
85
if [ -n "$check_mode" ]; then
80
86
 
81
 
        log "\n${bold} >> Verifying Prey installation...${bold_end}\n"
 
87
        log "\n${bold} == Verifying Prey installation...${bold_end}\n"
82
88
        verify_installation
83
89
 
84
90
        if [ "$post_method" == "http" ]; then
85
 
                log "\n${bold} >> Verifying API and Device keys...${bold_end}\n"
 
91
                log "\n${bold} == Verifying API and Device keys...${bold_end}\n"
86
92
                verify_keys
87
93
        elif [ "$post_method" == "email" ]; then
88
 
                log "\n${bold} >> Verifying SMTP settings...${bold_end}\n"
 
94
                log "\n${bold} == Verifying SMTP settings...${bold_end}\n"
89
95
                verify_smtp_settings
90
96
        fi
91
97
 
94
100
fi
95
101
 
96
102
####################################################################
 
103
# wait a few seconds to make sure our request doesn't get dropped
 
104
# due to clashes with the other zillion requests to the CP
 
105
####################################################################
 
106
 
 
107
# only do this if Prey is being run from cron in Mac and Linux
 
108
if [[ "$os" != "windows" && -n "$(running_from_cron)" && "$post_method" == "http" ]]; then
 
109
        seconds_to_wait=$(get_random_number 59)
 
110
        log " -- Pausing for ${seconds_to_wait} seconds..."
 
111
        sleep $seconds_to_wait
 
112
fi
 
113
 
 
114
####################################################################
97
115
# if there's a URL in the config, lets see if it actually exists
98
116
# if it doesn't, the program will shut down gracefully
99
117
####################################################################
102
120
create_tmpdir
103
121
 
104
122
if [[ $connected == 1 && -n "$check_url" ]]; then
 
123
 
105
124
        log "$STRING_CHECK_URL"
106
125
 
 
126
        log "\n${bold} == Verifying status...${bold_end}\n"
107
127
        check_device_status
108
128
 
109
 
        process_config
110
 
        process_module_config
111
 
 
112
 
        log "\n${bold} >> Verifying status...${bold_end}\n"
113
 
        log " -- Got status code $response_status!"
114
 
 
115
 
        if [ "$response_status" == "$missing_status_code" ]; then
116
 
 
117
 
                log "$STRING_PROBLEM"
118
 
 
119
 
                ####################################################################
120
 
                # initialize and fire off active modules
121
 
                ####################################################################
122
 
 
123
 
                set +e # error mode off, just continue if a module fails
124
 
                log " -- Running active report modules..."
125
 
                run_active_modules # on http mode this will only be report modules
126
 
 
127
 
                ####################################################################
128
 
                # lets send whatever we've gathered
129
 
                ####################################################################
130
 
 
131
 
                log "\n${bold} >> Sending report!${bold_end}\n"
132
 
                send_report
133
 
 
134
 
                log "\n$STRING_DONE"
 
129
        if [ -z "$response_status" ]; then
 
130
 
 
131
                log_response_error "$check_url"
135
132
 
136
133
        else
137
 
                log "$STRING_NO_PROBLEM"
 
134
 
 
135
                log " -- Got status code $response_status!"
 
136
                [ "$response_status" == "$missing_status_code" ] && device_missing=1
 
137
                process_config
 
138
                process_module_config
 
139
 
 
140
                if [ -n "$device_missing" ]; then
 
141
 
 
142
                        log "$STRING_PROBLEM"
 
143
 
 
144
                        ####################################################################
 
145
                        # initialize and fire off active modules
 
146
                        ####################################################################
 
147
 
 
148
                        set +e # error mode off, just continue if a module fails
 
149
                        log " -- Running active report modules..."
 
150
                        run_active_modules
 
151
 
 
152
                        ####################################################################
 
153
                        # lets send whatever we've gathered
 
154
                        ####################################################################
 
155
 
 
156
                        log "\n${bold} == Sending report!${bold_end}\n"
 
157
                        send_report
 
158
 
 
159
                        log "\n$STRING_DONE"
 
160
 
 
161
                else
 
162
 
 
163
                        log "$STRING_NO_PROBLEM"
 
164
 
 
165
                fi
 
166
 
138
167
        fi
 
168
 
139
169
fi
140
170
 
141
171
####################################################################
142
172
# if we have any pending actions, run them
143
173
####################################################################
144
174
 
145
 
if [ -n "$offline_mode" ]; then
146
 
        process_module_config
147
 
fi
148
 
 
149
175
check_running_actions
150
176
 
151
177
if [ "${#actions[*]}" -gt 0 ]; then