Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Added default.config. Evenually we will remove config from the repo i…
Browse files Browse the repository at this point in the history
…tself, so updater must know how to pass configuration settings from one file to the other
  • Loading branch information
tomas committed Jul 29, 2010
1 parent f8e3a4b commit aa66078
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
93 changes: 93 additions & 0 deletions config.default
@@ -0,0 +1,93 @@
#!/bin/bash
####################################################################
# PREY Configuration File - by Tomas Pollak (bootlog.org)
# URL: http://preyproject.com
# License: GPLv3
####################################################################

# language, en (english) or es (espanol)
lang='en'

# autoconnect feature, disabled by default until we are 200% sure it
# works flawlessly in all platforms. feel free to try it out though.
auto_connect='n'

# verification URL, if left empty Prey will always activate and run,
# which is certainly *not* recommended.
check_url='http://control.preyproject.com'

# IMPORTANT: on what HTTP response code will Prey be activated (200 or 404)
# control panel users don't touch this! standalone users may want to
# change it back to 200 (previous setting), if you wish to wake Prey up by
# creating the URL (as before) instead of removing an existing one
missing_status_code='404'

# you can use send the report via email or to the web service
# valid values: http, email, scp or sftp
post_method='http'

####################################################################
# http posting configuration
####################################################################

# you can get both of these from Prey's web service
api_key=''
device_key=''

####################################################################
# SMTP settings, for email posting
####################################################################

# mailbox to send the report
mail_to='mailbox@domain.com'

# the password is now stored base64 encrypted
# if you wish to generate it by hand, run
# $ echo -n "password" | openssl enc -base64
smtp_server='smtp.gmail.com:587'
smtp_username='username@gmail.com'
smtp_password='password'

# you dont need to change this
mail_from='Prey <no-reply@gmail.com>'
mail_subject='[Prey] Status Report'

####################################################################
# additional http options
####################################################################

# if you're having trouble getting requests across your firewall or proxy,
# you can try adding '-0' to make curl perform HTTP 1.0 requests
curl_options='--compress'

# this option prepends a random number as a subdomain to the check URL on http mode
# makes it harder for other programs to block Prey so its a good idea to be on
randomize_check_host='n'

# whether to send your device's LAN and gateway IP address as headers when
# checking its status. currently only for testing purposes, but maybe in the
# future it may prove useful. :)
extended_headers='n'

####################################################################
# scp/sftp posting configuration -- EXPERIMENTAL!
# we dont use user/pass but RSA keys
# for more info check http://tinyurl.com/sshtip
####################################################################

# this applies both to scp and sftp posting methods
ssh_options='-oStrictHostKeyChecking=no'

# remember you should have write access to the folder
scp_user='username'
scp_server='my.server.com'
scp_path='~'

# same as above, make sure you have write access
sftp_user='username'
sftp_server='my.server.com'
sftp_path='.'

####################################################################
# if you have any questions please visit preyproject.com
####################################################################
1 change: 1 addition & 0 deletions core/setup
Expand Up @@ -69,6 +69,7 @@ set_constants(){
readonly lang
readonly start_time=`date +"%F %T"`

readonly config_file="$base_path/config"
readonly tmpdir="$tmpbase/p${RANDOM}"
readonly last_response="$tmpbase/last_response.tmp"
readonly logged_user
Expand Down
33 changes: 33 additions & 0 deletions core/updater
Expand Up @@ -219,6 +219,7 @@ apply_changes(){
perform_update() {

pre_update_hook
backup_config

log "\n${bold} >> Applying changes!${bold_end}\n"
sleep 1
Expand Down Expand Up @@ -246,6 +247,8 @@ perform_update() {
report_update_status $update_status
delete_tmpdir

# update_config

log ' -- Running post-update hooks...'
post_update_hook $update_status
run_post_update_script
Expand Down Expand Up @@ -289,6 +292,36 @@ run_post_update_script(){
fi
}

backup_config(){
log ' -- Backing up current settings...'
backup_config_file="$base_path/config.backup"
cp "$config_file" "$backup_config_file"
}

set_config_value(){
sed -i -e "s/^$1=.*$/$1='$2'/" $config_file 2> /dev/null
}

update_config(){
default_config_file="$base_path/config.default"
if [ ! -f "$default_config_file" ]; then
cp "$backup_config_file" "$config_file"
return 1
else
cp "$default_config_file" "$config_file"
log ' -- Applying current config settings to new config file...'
# parse file and remove all comments and empty lines
config_options=`cat "$backup_config_file" | grep -v '^#' | grep -v "^$" | sed 's/ /-SPACE-/'`
for option in $config_options; do
local option_name=`echo "$option" | sed 's/=.*//'`
local option_value=`echo "$option" | sed -e 's/[^=]*=//' -e "s/^'//" -e "s/'$//" -e "s/\//-SLASH-/g"`
set_config_value "$option_name" "$option_value"
done
sed -i -e "s/-SLASH-/\//g" -e "s/-SPACE-/ /g" $config_file # resolve the slash and space hacks
log ' -- Done!'
fi
}

####################################################################
# module updater
####################################################################
Expand Down

0 comments on commit aa66078

Please sign in to comment.