#!/bin/bash
####################################################################
# Prey Lock Module Core Functions - by Tomas Pollak (bootlog.org)
# URL: http://preyproject.com
# License: GPLv3
####################################################################

# set -bm

before_lock_callback(){
	log " -- Running lock before callback."
}

after_lock_callback(){
	log " -- Running lock after callback."
}

activate_lock(){

	if [ -n "`is_process_running 'prey-lock'`" ]; then
		log ' -- Prey lock seems to be running already!'
		return 1
	fi

	before_lock_callback
	local command="\"$lock__executable\" `md5_hash_for $lock__unlock_pass`"
	run_as_current_user "$command" &
	# trap 'reactivate_lock' SIGCHLD
	pid=$!
	wait $pid
	rs=$?
	# echo  "return status was: $rs"
	if [ $rs -eq 66 ]; then
		deactivate_modules_on_panel "lock"
	elif [ $rs != 0 ]; then
		activate_lock
		return
	fi
	after_lock_callback

}
