This repository has been archived by the owner on Oct 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
74 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ Create a file in /etc/profile.d/ipteller.sh with the variables: | |
```bash | ||
export GMAIL_USER='[email protected]' | ||
export GMAIL_PASS='Password' | ||
export IP_PROVIDER='jsonip' | ||
``` | ||
|
||
and then in execute `crontab -e` and add this line at the end: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ services: | |
PYTHONUSERBASE: /app/vendor | ||
PYTHONPATH: '/app/vendor/lib/python2.7/site-packages' | ||
PATH: '/app/vendor/bin:$PATH' | ||
IP_PROVIDER: 'jsonip' | ||
TWINE_USERNAME: 'User' | ||
TWINE_PASSWORD: 'Password' | ||
GMAIL_USER: '[email protected]' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env python | ||
|
||
from providerip import ProviderIp | ||
|
||
|
||
class IpIfy(ProviderIp): | ||
def __init__(self): | ||
ProviderIp.__init__(self) | ||
self.url = 'https://api.ipify.org?format=json' | ||
|
||
@staticmethod | ||
def get_ip(uri): | ||
return uri["ip"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
#!/usr/bin/env python | ||
"""This script runs the whole app""" | ||
|
||
from os import environ | ||
from address import Address | ||
from ipify import IpIfy | ||
from jsonip import JsonIp | ||
from mailer import Mailer | ||
|
||
address = Address('address.txt') | ||
provider = JsonIp() | ||
try: | ||
user = environ["GMAIL_USER"] | ||
pwd = environ["GMAIL_PASS"] | ||
except KeyError as err: | ||
print('You need to add the environment variable: %s' % err) | ||
quit(1) | ||
try: | ||
provider = environ["IP_PROVIDER"] | ||
if provider == 'ipify': | ||
provider = IpIfy() | ||
else: | ||
raise KeyError | ||
except KeyError: | ||
provider = JsonIp() | ||
|
||
ip = provider.get_ip(provider.get_response()) | ||
|
||
if ip != address.load(): | ||
address.save(ip) | ||
deliver = Mailer('IP Teller', 'Your IP changed to: ' + ip).send() | ||
data = {'user': user, 'pwd': pwd, 'subject': 'IP Teller', 'body': 'Your IP changed to: %s' % ip} | ||
deliver = Mailer().send(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python | ||
|
||
import logging | ||
import requests | ||
|
||
|
||
class ProviderIp(object): | ||
def __init__(self): | ||
self.url = '' | ||
|
||
def get_response(self): | ||
try: | ||
return requests.get(self.url).json() | ||
except ValueError as err: | ||
logging.exception(err) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
GH=https://github.com/Saphyel/ipteller/compare/ | ||
LAST_TAG=`git describe --tags --abbrev=0 HEAD^` | ||
LAST_TAG=`git describe --tags --abbrev=0 origin/master` | ||
TMP_FILE=CHANGELOG.md | ||
|
||
printf "**Changelog** (since "${GH}${LAST_TAG}"...NEW)\n" > CHANGELOG.md | ||
git log ${LAST_TAG}..HEAD --pretty=format:"* %s" >> CHANGELOG.md | ||
printf "\n" >> CHANGELOG.md | ||
git fetch origin | ||
printf "**Changelog** (since "${GH}${LAST_TAG}"...NEW)\n" > ${TMP_FILE} | ||
git log ${LAST_TAG}..HEAD --pretty=format:"* %s" >> ${TMP_FILE} | ||
printf "\n" >> ${TMP_FILE} | ||
cat ${TMP_FILE} && rm ${TMP_FILE} |