Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added comments & reboot modification #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
IFTTT-Remote-Control
====================

Run preset commands on a linux computer via text message

###Introduction###

This project works thanks to [IFTTT](https://ifttt.com) and [Dropbox](https://www.dropbox.com). IFTTT receives a text and syncs it to the computer via Dropbox. Then a script will check for the existence of the file and if it is there, run a command.

###Implementation###

####Dropbox####

1. You will need to create an account if you haven't already.
2. Dropbox can be downloaded from [https://www.dropbox.com/install](https://www.dropbox.com/install)
3. See the [Dropbox Wiki](http://www.dropboxwiki.com/Text_Based_Linux_Install#Running_on_system_startup) for configuring Dropbox to run at startup

####IFTTT####

1. Create an account if you haven't already
2. Go to [https://ifttt.com/recipes/85666](https://ifttt.com/recipes/85666) activate the Dropbox and SMS channels if they aren't already, customize as needed, then click "Use Recipe"

####Script####

1. Download the script ```iftttcontrol.sh``` from this repository
2. Edit the variables at the beginning of the file for the IFTTT folder location and where you want a log to be stored
3. Edit the command variables if you are using different IFTTT text tags
4. You may want to move the script to a safe location and change the owner to root so it can't be edited too easily

####Cron####

1. Since commands such as ```shutdown``` require root, I used the crontab at /etc/crontab to do so
2. This is the line that I entered in crontab to run the script every minute, where "```/etc/ifttt/iftttcontrol.sh```" is the location of the script, it may be different for you:
```*/1 * * * * root sh /etc/ifttt/iftttcontrol.sh```

###Pushover Notifications###

If you would like to receive [Pushover](https://pushover.net) notifications, use the iftttcontrolnotify.sh file instead of the iftttcontrol.sh file.
IFTTT-Remote-Control
====================
Run preset commands on a linux computer via text message
###Introduction###
This project works thanks to [IFTTT](https://ifttt.com) and [Dropbox](https://www.dropbox.com). IFTTT receives a text and syncs it to the computer via Dropbox. Then a script will check for the existence of the file and if it is there, run a command.
###Implementation###
####Dropbox####
1. You will need to create an account if you haven't already.
2. Dropbox can be downloaded from [https://www.dropbox.com/install](https://www.dropbox.com/install)
3. See the [Dropbox Wiki](http://www.dropboxwiki.com/Text_Based_Linux_Install#Running_on_system_startup) for configuring Dropbox to run at startup
####IFTTT####
1. Create an account if you haven't already
2. Go to [https://ifttt.com/recipes/85666](https://ifttt.com/recipes/85666) activate the Dropbox and SMS channels if they aren't already, customize as needed, then click "Use Recipe"
####Script####
1. Download the script ```iftttcontrol.sh``` from this repository
2. Edit the variables at the beginning of the file for the IFTTT folder location and where you want a log to be stored
3. Edit the command variables if you are using your own IFTTT text tags
4. You may want to move the script to a safe location and change the owner to root so it can't be edited too easily
####Cron####
1. Since commands such as ```shutdown``` require root, I used the crontab at /etc/crontab to do so
2. This is the line that I entered in crontab to run the script every minute, where "```/etc/ifttt/iftttcontrol.sh```" is the location of the script, it may be different for you:
```*/1 * * * * root sh /etc/ifttt/iftttcontrol.sh```
###Pushover Notifications###
If you would like to receive [Pushover](https://pushover.net) notifications, use the iftttcontrolnotify.sh file instead of the iftttcontrol.sh file.
Be sure to set the POTOKEN and POUSER variables.
66 changes: 38 additions & 28 deletions iftttcontrol.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
#!/bin/sh
#This script checks for a Dropbox-synced file and then runs a preconfigured command accordingly

IFTTTLOCATION="/home/username/Dropbox/IFTTT"
LOGLOCATION="/home/username/IFTTT.log"
SLEEP="sleep"
REBOOT="reboot"
SHUTDOWN="shutdown"
Date=$(date +"%Y-%m-%d %T")

if [ -e $IFTTTLOCATION/$SLEEP.txt ]; then
rm $IFTTTLOCATION/$SLEEP.txt
echo "$Date - Going to sleep" >> $LOGLOCATION
pm-suspend
exit 0
fi
if [ -e $IFTTTLOCATION/$REBOOT.txt ]; then
rm $IFTTTLOCATION/$REBOOT.txt
echo "$Date - Rebooting" >> $LOGLOCATION
reboot
exit 0
fi
if [ -e $IFTTTLOCATION/$SHUTDOWN.txt ]; then
rm $IFTTTLOCATION/$SHUTDOWN.txt
echo "$Date - Shutting down" >> $LOGLOCATION
shutdown now
exit 0
fi
#!/bin/sh
#This script checks for a Dropbox-synced file and then runs a preconfigured command accordingly

#Dropbox folder and log lcoation of choosing
IFTTTLOCATION="/home/username/Dropbox/IFTTT"
LOGLOCATION="/home/username/IFTTT.log"
Date=$(date +"%Y-%m-%d %T")

#Add custom variables here to trigger custom commands
SLEEP="sleep"
REBOOT="reboot"
SHUTDOWN="shutdown"

#Sleep
if [ -e $IFTTTLOCATION/$SLEEP.txt ]; then
rm $IFTTTLOCATION/$SLEEP.txt
echo "$Date - Going to sleep" >> $LOGLOCATION
pm-suspend
exit 0
fi

#Reboot
if [ -e $IFTTTLOCATION/$REBOOT.txt ]; then
rm $IFTTTLOCATION/$REBOOT.txt
echo "$Date - Rebooting" >> $LOGLOCATION
init 6
exit 0
fi

#Shutdown
if [ -e $IFTTTLOCATION/$SHUTDOWN.txt ]; then
rm $IFTTTLOCATION/$SHUTDOWN.txt
echo "$Date - Shutting down" >> $LOGLOCATION
shutdown now
exit 0
fi

#Add custom commands here following example formatting
exit 0
113 changes: 63 additions & 50 deletions iftttcontrolnotify.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,64 @@
#/bin/sh
#This script checks for a Dropbox-synced file and then runs a preconfigured command accordingly
#It also sends a notification to your devices via Pushover (pushover.net)

IFTTTLOCATION="/home/username/Dropbox/IFTTT"
LOGLOCATION="/home/username/IFTTT.log"
SLEEP="sleep"
REBOOT="reboot"
SHUTDOWN="shutdown"
POTOKEN="000000000000"
POUSER="000000000000"
POSOUND="intermission"
Date=$(date +"%Y-%m-%d %T")

if [ -e $IFTTTLOCATION/$SLEEP.txt ]; then
rm $IFTTTLOCATION/$SLEEP.txt
curl -s \
-F "token=$POTOKEN" \
-F "user=$POUSER" \
-F "message=Sleeping at $Date" \
-F "sound=$POSOUND" \
https://api.pushover.net/1/messages.json
echo "$Date - Going to sleep" >> $LOGLOCATION
pm-suspend
exit 0
fi
if [ -e $IFTTTLOCATION/$REBOOT.txt ]; then
rm $IFTTTLOCATION/$REBOOT.txt
curl -s \
-F "token=$POTOKEN" \
-F "user=$POUSER" \
-F "message=Rebooting at $Date" \
-F "sound=$POSOUND" \
https://api.pushover.net/1/messages.json
echo "$Date - Rebooting" >> $LOGLOCATION
reboot
exit 0
fi
if [ -e $IFTTTLOCATION/$SHUTDOWN.txt ]; then
rm $IFTTTLOCATION/$SHUTDOWN.txt
curl -s \
-F "token=$POTOKEN" \
-F "user=$POUSER" \
-F "message=Shutting down at $Date" \
-F "sound=$POSOUND" \
https://api.pushover.net/1/messages.json
echo "$Date - Shutting down" >> $LOGLOCATION
shutdown now
exit 0
fi
#/bin/sh
#This script checks for a Dropbox-synced file and then runs a preconfigured command accordingly
#It also sends a notification to your devices via Pushover (pushover.net)

#Dropbox folder and log lcoation of choosing
IFTTTLOCATION="/home/username/Dropbox/IFTTT"
LOGLOCATION="/home/username/IFTTT.log"
Date=$(date +"%Y-%m-%d %T")

#Add custom variables here to trigger custom commands
SLEEP="sleep"
REBOOT="reboot"
SHUTDOWN="shutdown"

#Pushover configuration
POTOKEN="000000000000"
POUSER="000000000000"
POSOUND="intermission"

#Sleep
if [ -e $IFTTTLOCATION/$SLEEP.txt ]; then
rm $IFTTTLOCATION/$SLEEP.txt
curl -s \
-F "token=$POTOKEN" \
-F "user=$POUSER" \
-F "message=Sleeping at $Date" \
-F "sound=$POSOUND" \
https://api.pushover.net/1/messages.json
echo "$Date - Going to sleep" >> $LOGLOCATION
pm-suspend
exit 0
fi

#Reboot
if [ -e $IFTTTLOCATION/$REBOOT.txt ]; then
rm $IFTTTLOCATION/$REBOOT.txt
curl -s \
-F "token=$POTOKEN" \
-F "user=$POUSER" \
-F "message=Rebooting at $Date" \
-F "sound=$POSOUND" \
https://api.pushover.net/1/messages.json
echo "$Date - Rebooting" >> $LOGLOCATION
init 6
exit 0
fi

#Shutdown
if [ -e $IFTTTLOCATION/$SHUTDOWN.txt ]; then
rm $IFTTTLOCATION/$SHUTDOWN.txt
curl -s \
-F "token=$POTOKEN" \
-F "user=$POUSER" \
-F "message=Shutting down at $Date" \
-F "sound=$POSOUND" \
https://api.pushover.net/1/messages.json
echo "$Date - Shutting down" >> $LOGLOCATION
shutdown now
exit 0
fi


#Add custom commands here following example formatting
exit 0