Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PART 1 INSTALL MOTION DULU
- ################################################
- 1.opkg install motion
- nano /etc/default/motion
- 2.start_motion_daemon=yes
- 3.nano /etc/motion/motion.conf
- daemon
- set to on
- width
- set to 320
- height
- set to 240
- webcam_localhost
- set to off
- webcam_port
- set to 8291 # terserah port berapa
- target_dir
- change to target_dir /data/webcam/motion
- 4.chmod 664 /etc/motion.conf
- 5.chmod 755 /usr/bin/motion
- 6.touch /var/log/motion.log
- 7.chmod 777 /var/log/motion.log
- 8.nano /bin/startmotion.sh
- LOG=/var/log/motion.log
- echo "Start Motion Script" `date` >> /var/log/motion.log
- /usr/bin/motion 2>&1 | tee -a $LOG &
- ctrl + x yes
- 9.nano /bin/stopmotion.sh
- #!/bin/bash
- LOG=/var/log/motion.log
- # Script details
- echo "Stop Motion Script" `date` >> /var/log/motion.log
- pkill motion 2>&1 | tee -a $LOG
- ctrl + x yes
- 10.chmod u+x /bin/startmotion.sh
- 11.chmod 755 /bin/startmotion.sh
- 12.chmod u+x /bin/stopmotion.sh
- 13.chmod 755 /bin/stopmotion.sh
- startmotion.sh >>>>>>>>> untuk menjalankan motion
- stopmotion.sh >>>>>>>>> untuk stop motion
- ###############################################################################
- PART 2 INSTALL PAKET EMAIL
- 1.opkg install ssmtp
- 2.nano /etc/ssmtp/ssmtp.conf
- #root=your_username@yahoo.com # Uncomment this line and comment the following if using yahoo
- root=isi email_juragan@gmail.com
- #mailhub=smtp.mail.yahoo.com:587 # Uncomment this line and comment the following if using yahoo
- mailhub=smtp.gmail.com:587
- #rewriteDomain=yahoo.com # Uncomment this line and comment the following if using yahoo
- rewriteDomain=gmail.com
- #hostname=your_username@yahoo.com # Uncomment this line and comment the following if using yahoo
- hostname=root
- # Use SSL/TLS before starting negotiation
- #UseTLS=Yes
- UseSTARTTLS=Yes
- # Username/Password
- AuthUser=email_juragan@gmail.com # <<< isi email juragan
- AuthPass=password_juragan # <<< isi password juragan
- # Email 'From header's can override the default domain?
- FromLineOverride=yes
- 3.chmod 774 /etc/ssmtp/ssmtp.conf
- 4.chown root:mail /etc/ssmtp/ssmtp.conf
- 5.nano /etc/ssmtp/revaliases
- #root:your_username@yahoo.com:smtp.mail.yahoo.com:587 # Uncomment this line and comment the following if using yahoo
- root:email_juragan@gmail.com:smtp.gmail.com:587
- 6.opkg install zip
- 7.opkg install mutt
- 8.mkdir -p ~/.mutt/cache/{headers,bodies}
- 9.mkdir ~/.mutt/certificates
- 10.nano ~/.muttrc
- set sendmail="/usr/sbin/ssmtp"
- # replace with your email address, should be the same address as what you've us$
- set from="email_juragan@gmail.com"
- set use_from=yes
- #end-----------------------------------------
- 11.nano /bin/zipandmail.sh
- #!/bin/bash
- #Yahoo and Gmail only allow attachment size of 25MB.
- #For example, 800x608 @ 50% motion detection jpegs, each file is 33~43KB.
- #Each folder should about 500 files so as not to exceed 20MB when zipped.
- #Change the default 500 to a smaller value if your recipient's email provider's$
- #splitsize=250
- splitsize=50
- #Email recipient(s), separated by space
- recipient="email_juragan@gmail.com" # isi email juragan.klo mau kirim ke satu email
- #recipient="foo@gmail.com foo@yahoo.com" # kalo mau kirim ke 2 email
- #Email subject and message
- message="Isi mail"
- #Motion target files path
- targetfilepath="/data/webcam/motion"
- #Motion target directory path
- targetdirpath="/data/webcam"
- ####################################
- echo "Menjalankan zipandmail.sh..." `date`
- #count number of files in motion directory
- numfiles=$( ls -l $targetfilepath | egrep -c '^-')
- numfolders=`expr $numfiles / $splitsize`
- lastfoldercount=`expr $numfiles % $splitsize`
- echo $numfiles
- #echo $numfolders
- #echo $lastfoldercount
- #Move all files from motion directory to newly created directories based on $nu$
- COUNTER=0
- while [ $COUNTER -le $numfolders ]; do
- echo "Mencari directory... " `date`
- destination="$targetfilepath$COUNTER"
- rm -rf $destination
- mkdir -p $destination
- #move multiples of $splitsize files to new folder(s) except the remainder files$
- if [ "$COUNTER" -lt "$numfolders" ]; then
- for file in $(ls -p $targetfilepath | grep -v / | tail -$splitsize); do
- mv $targetfilepath/$file $destination
- done
- #move remainder files in last new motion folder
- else
- for file in $(ls -p $targetfilepath | grep -v / | tail -$lastfoldercount); $
- mv $targetfilepath/$file $destination
- done
- fi
- echo "Membuat zip file... " `date`
- pushd $targetdirpath
- zip -9 -r -q motion$COUNTER.zip ./motion$COUNTER/
- popd
- echo "Mengirim mail ke penerima... " `date`
- echo $message | mutt -s "subject of the email" $recipient -a $targetfilepath$$
- let COUNTER=COUNTER+1
- done
- 12.zipandmail.sh <<<<< untuk menjalankan perintah zip file jpg,trus kirim ke email juragan
Add Comment
Please, Sign In to add comment