Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 0 9 * * * root /usr/bin/lwp-request http://localhost:8080/0/detection/start > /dev/null
- sudo /usr/bin/wget http://localhost:8091/0/config/set?threshold=1000&username=myuserename&password=mypassword> /dev/null
- sudo /usr/bin/wget -O /dev/null -q http://localhost:8091/0/config/set?threshold=1000&username=myuserename&password=mypassword
- #!/usr/bin/env python
- ###############################################################################
- # This script opens Motion's configuration file, searches through it for
- # "from" then copies the contents and replacements "to"
- # (eg from = threshold 300 to threshold 6000) to the tmp.conf file.
- # It then renames the un-modified existing motion.conf file to
- # "motion_old.conf" for backup purposes; before renaming the "temp.conf" to
- # "motion.conf", the new modified file.
- # It then sets the new motion.conf file to user "motion" and group "motion",
- # before restarting motion.
- ###############################################################################
- ###############################################################################
- # call the script from cronjob for 5:30AM
- #
- # 30 5 * * * sudo /usr/src/scripts/mod_file/modify_motionconf_night_to_day_garden.py
- #
- ###############################################################################
- import os, sys
- infile = open('/etc/motion.conf') # the motion.conf file that will be renamed for backup purposes
- outfile = open('/etc/tmp.conf', 'w') # temp file to write to
- # from to
- replacements = {'threshold 300':'threshold 6000', 'text_left garden cam night':'text_left garden cam day', '#----night----#':'#----day----#'}
- # threshold 189 text_left 389 #----xxx----# 5 line numbers in motion.conf
- ############################################################################### search and create new temp file part
- for line in infile:
- for src, target in replacements.items():
- line = line.replace(src, target)
- outfile.write(line)
- infile.close()
- outfile.close()
- ############################################################################### search and create new temp file part end
- #os.remove('/etc/motion.conf') # uncomment if you don't want a backup
- os.rename("/etc/motion.conf","/etc/motion_old.conf")
- #delay or not?
- os.rename("/etc/tmp.conf","/etc/motion.conf")
- os.system("chown :motion /etc/motion.conf")
- os.system("chown motion /etc/motion.conf")
- os.system("sudo /etc/init.d/motion restart")
- man wget
- --user=user
- --password=password
- Specify the username user and password password for both FTP and HTTP file retrieval.
- sudo /usr/bin/wget -O /dev/null --user=myuserename --password=mypassword http://localhost:8091/0/config/set?threshold=1000
- 0 8 * * 1-5 sudo /usr/bin/wget -O /dev/null --user=myuser --password=mypassword http://localhost:80/0/detection/pause
- 0 18 * * 1-5 sudo /usr/bin/wget -O /dev/null --user=myuser --password=mypassword http://localhost:80/0/detection/start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement