Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------
- /etc/rc.local
- ----------------------------------------------------------------
- #!/bin/sh -e
- #
- # rc.local
- #
- # This script is executed at the end of each multiuser runlevel.
- # Make sure that the script will "exit 0" on success or any other
- # value on error.
- #
- # In order to enable or disable this script just change the execution
- # bits.
- #
- # By default this script does nothing.
- # Print the IP address
- _IP=$(hostname -I) || true
- if [ "$_IP" ]; then
- printf "My IP address is %s\n" "$_IP"
- fi
- python /home/pi/Call_Button.py
- exit 0
- -------------------------------------------------------------------------
- /etc/sudoers.tmp ######### modify using visudo only! #########
- -------------------------------------------------------------------------
- #
- # This file MUST be edited with the 'visudo' command as root.
- #
- # Please consider adding local content in /etc/sudoers.d/ instead of
- # directly modifying this file.
- #
- # See the man page for details on how to write a sudoers file.
- #
- Defaults env_reset
- Defaults mail_badpass
- Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
- # Host alias specification
- # User alias specification
- # Cmnd alias specification
- # User privilege specification
- root ALL=(ALL:ALL) ALL
- # Allow members of group sudo to execute any command
- %sudo ALL=(ALL:ALL) ALL
- # See sudoers(5) for more information on "#include" directives:
- #includedir /etc/sudoers.d
- pi ALL=(ALL) NOPASSWD: ALL
- #asterisk ALL = NOPASSWD: /usr/share/asterisk/agi-bin/unlock_door.py
- -------------------------------------------------------------------------
- /home/pi/Call_button.py
- -------------------------------------------------------------------------
- import RPi.GPIO as GPIO
- import time
- import os
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(4,GPIO.IN)
- input = GPIO.input(4)
- while True:
- input = GPIO.input(4)
- if(not input):
- # print("Button pressed")
- os.system("asterisk -x \"console dial 698\"")
- time.sleep(01)
- --------------------------------------------------------------
- /usr/share/asterisk/agi-bin/unlock_door
- --------------------------------------------------------------
- #!/usr/bin/perl
- $|=1;
- system 'sudo /usr/share/asterisk/agi-bin/unlock_door.py';
- sleep 3;
- --------------------------------------------------------------
- /usr/share/asterisk/agi-bin/unlock_door.py
- --------------------------------------------------------------
- #!/usr/bin/env python
- import RPi.GPIO as GPIO
- import time
- import logging
- logging.basicConfig(filename='/home/pi/door_trigger.log',level=logging.DEBUG ,format='%(asctime)s %(message)s')
- logging.info('Door Unlocked!')
- GPIO.setwarnings(False)
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(17, GPIO.OUT)
- GPIO.output(17,True)
- time.sleep(5.0)
- GPIO.output(17,False)
- -------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement