Advertisement
Guest User

Untitled

a guest
May 5th, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. 0 9 * * * root /usr/bin/lwp-request http://localhost:8080/0/detection/start > /dev/null
  2.  
  3. sudo /usr/bin/wget http://localhost:8091/0/config/set?threshold=1000&username=myuserename&password=mypassword> /dev/null
  4.  
  5. sudo /usr/bin/wget -O /dev/null -q http://localhost:8091/0/config/set?threshold=1000&username=myuserename&password=mypassword
  6.  
  7. #!/usr/bin/env python
  8.  
  9. ###############################################################################
  10. # This script opens Motion's configuration file, searches through it for
  11. # "from" then copies the contents and replacements "to"
  12. # (eg from = threshold 300 to threshold 6000) to the tmp.conf file.
  13. # It then renames the un-modified existing motion.conf file to
  14. # "motion_old.conf" for backup purposes; before renaming the "temp.conf" to
  15. # "motion.conf", the new modified file.
  16. # It then sets the new motion.conf file to user "motion" and group "motion",
  17. # before restarting motion.
  18. ###############################################################################
  19.  
  20. ###############################################################################
  21. # call the script from cronjob for 5:30AM
  22. #
  23. # 30 5 * * * sudo /usr/src/scripts/mod_file/modify_motionconf_night_to_day_garden.py
  24. #
  25. ###############################################################################
  26.  
  27. import os, sys
  28.  
  29. infile = open('/etc/motion.conf') # the motion.conf file that will be renamed for backup purposes
  30. outfile = open('/etc/tmp.conf', 'w') # temp file to write to
  31.  
  32. # from to
  33. replacements = {'threshold 300':'threshold 6000', 'text_left garden cam night':'text_left garden cam day', '#----night----#':'#----day----#'}
  34. # threshold 189 text_left 389 #----xxx----# 5 line numbers in motion.conf
  35.  
  36. ############################################################################### search and create new temp file part
  37. for line in infile:
  38. for src, target in replacements.items():
  39. line = line.replace(src, target)
  40. outfile.write(line)
  41. infile.close()
  42. outfile.close()
  43. ############################################################################### search and create new temp file part end
  44.  
  45. #os.remove('/etc/motion.conf') # uncomment if you don't want a backup
  46. os.rename("/etc/motion.conf","/etc/motion_old.conf")
  47. #delay or not?
  48. os.rename("/etc/tmp.conf","/etc/motion.conf")
  49. os.system("chown :motion /etc/motion.conf")
  50. os.system("chown motion /etc/motion.conf")
  51.  
  52. os.system("sudo /etc/init.d/motion restart")
  53.  
  54. man wget
  55.  
  56. --user=user
  57. --password=password
  58. Specify the username user and password password for both FTP and HTTP file retrieval.
  59.  
  60. sudo /usr/bin/wget -O /dev/null --user=myuserename --password=mypassword http://localhost:8091/0/config/set?threshold=1000
  61.  
  62. 0 8 * * 1-5 sudo /usr/bin/wget -O /dev/null --user=myuser --password=mypassword http://localhost:80/0/detection/pause
  63.  
  64. 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