View difference between Paste ID: siZgj1rg and F4YaU5tB
SHOW: | | - or go back to the newest paste.
1
----------------------------------------------------------------
2
/etc/rc.local
3
----------------------------------------------------------------
4
#!/bin/sh -e
5
#
6
# rc.local
7
#
8
# This script is executed at the end of each multiuser runlevel.
9
# Make sure that the script will "exit 0" on success or any other
10
# value on error.
11
#
12
# In order to enable or disable this script just change the execution
13
# bits.
14
#
15
# By default this script does nothing.
16
17
# Print the IP address
18
_IP=$(hostname -I) || true
19
if [ "$_IP" ]; then
20
  printf "My IP address is %s\n" "$_IP"
21
fi
22
23
python /home/pi/Call_Button.py
24
25
exit 0
26
-------------------------------------------------------------------------
27
/etc/sudoers.tmp ######### modify using visudo only! #########
28
-------------------------------------------------------------------------
29
#
30
# This file MUST be edited with the 'visudo' command as root.
31
#
32
# Please consider adding local content in /etc/sudoers.d/ instead of
33
# directly modifying this file.
34
#
35
# See the man page for details on how to write a sudoers file.
36
#
37
Defaults	env_reset
38
Defaults	mail_badpass
39
Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
40
41
# Host alias specification
42
43
# User alias specification
44
45
# Cmnd alias specification
46
47
# User privilege specification
48
root	ALL=(ALL:ALL) ALL
49
50
# Allow members of group sudo to execute any command
51
%sudo	ALL=(ALL:ALL) ALL
52
53
# See sudoers(5) for more information on "#include" directives:
54
55
#includedir /etc/sudoers.d
56
pi ALL=(ALL) NOPASSWD: ALL
57
58
#asterisk ALL = NOPASSWD: /usr/share/asterisk/agi-bin/unlock_door.py
59
60
------------------------------------------------------------------------- 
61
/home/pi/Call_button.py
62
-------------------------------------------------------------------------
63
import RPi.GPIO as GPIO
64
import time
65
import os
66
GPIO.setmode(GPIO.BCM)
67
GPIO.setup(4,GPIO.IN)
68
input = GPIO.input(4)
69
while True:
70
	input = GPIO.input(4)
71
	if(not input):
72
#		print("Button pressed")
73
		os.system("asterisk -x \"console dial 698\"")
74
time.sleep(01)
75
76
--------------------------------------------------------------
77
/usr/share/asterisk/agi-bin/unlock_door
78
--------------------------------------------------------------
79
#!/usr/bin/perl
80
$|=1;
81
system 'sudo /usr/share/asterisk/agi-bin/unlock_door.py';
82
sleep 3;
83
84
--------------------------------------------------------------
85
/usr/share/asterisk/agi-bin/unlock_door.py
86
--------------------------------------------------------------
87
#!/usr/bin/env python
88
89
import RPi.GPIO as GPIO
90
import time
91
import logging
92
logging.basicConfig(filename='/home/pi/door_trigger.log',level=logging.DEBUG ,format='%(asctime)s %(message)s')
93
logging.info('Door Unlocked!')
94
GPIO.setwarnings(False)
95
GPIO.setmode(GPIO.BCM)
96
GPIO.setup(17, GPIO.OUT)
97
GPIO.output(17,True)
98
time.sleep(5.0)
99
GPIO.output(17,False)
100
101
-------------------------------------------------------------