Making crontab send email through mailgun


I have 3 raspberry pis and they have some crons on it. Although this is nice, I have hard time to keep track of which pi does what and if its cron has successfully completed. Thankfully there is an easy solution for that: Send an email after every cron run with logs. However, ubuntu or jessie (pi version of linux) is not capable of sending emails out of box. At least as far as I understand that is the situation so we need a mail provider to send emails. I already have an account from mailgun so why not using it? Did some research and combined some short commands to achieve this.i assume here that you have opened a mailgun.org account and you use crontab as cron job tool on some debian backed environment. Install crontab if you do not have:sudo apt-get install crontab Check the cron jobs:crontab -l Add/Remove/Edit the cron jobs:crontab -e Install postfix for mail sending relaysudo apt-get -y install postfix Choose from the prompts Satellite system username: desired_username ...

Windows 10'da Ubuntu Bash modunu etkinleştirmek


Artık windows 10 ile beraber beta olarak ubuntu subsystem kullanabiliyoruz. Bu kesinlikle virtualbox ya da cygwin tarzı bi sanallaştırma değil daha native bir sistem. Uzun zamandır istenen bi özellikti ve sonunda Microsoft ekledi bunu. Aktifleştirmek çok kolay: Başlat (Win) -> Ayarlar (Settings) -> Update & security Gelişitiricler (For developers) -> Use developer features -> Geliştirici modu (Developer mode) Denetim masası (Control panel) -> Programlar (Programs) -> Turn on/off Windows features Yeniden başlat İlk çalıştırmada bash.exe yi kendiniz tetiklemeniz lazım. Başlat -> bash yazıp çalıştırın O sizi yönlendirecek ve bittiğinde artık başlat’a bash yazıp çalıştırabilirsiniz. gcc, apt-get, nano, ssh, python, grep, ack hemen hemen her şey var. Hızlı bi gcc örneği Dosyayı yarattouch hello.c İçine kodunu yaz:nano hello.c Aşağıdakini yapıştırın:/* Hello World program */#include<stdio.h>main(){ printf("Hello World");} GCC’yi ubuntuya kurar...

Google Cloud SDK - how to bring back dev_appserver.py


This weekend’s annoying problem is this. New gcloud SDK is great, it is installed through Ubuntu Software Center (apt-get) etc. However, when you install it like that, even though you can deploy the Google App Engine apps; you would not be able to run the local server to see your changes locally for the python GAE app. Example: Run the development server:dev_appserver.py main.app.yamlOutput: dev_appserver.py command not found List the components:gcloud components list│ Uninstalled │ gcloud app Python Extensions │ app-engine-python │ 6.1 MiB │ Install the python SDK to use dev_appserver.pygcloud components install app-engine-pythonOutput: You cannot perform this action because this Cloud SDK installation is managed by an external package manager. The reason is that it’s installed through apt-get, instead we should uninstall that version through apt and then reinstall in the old way.sudo apt-get updatesudo apt autoremove google-cloud-sdk Install in an old way, this will ask you...

Some nice #bash commands


#!/bin/bashMake all files lower case in the folder in linuxfor f in `find`; do mv -v "$f" "`echo $f | tr '[A-Z]' '[a-z]'`"; doneRename all files in the directory sequentiallya=1for i in *.mp4; do new=$(printf "%04d.mp4" "$a") #04 pad to length of 4 mv -- "$i" "$new" let a=a+1doneCheck if variable null (not set) or not if [ -z "$var" ] then echo "\$var is empty" fiFunction definitionmain (){ echo "This is a function" # Use the passed parameter in the function. echo "Passed parameter is $1"}main "first parameter"if-else conditionalsif [[ "$1" = "1" ]]; then echo "This is if"elif [[ "$1" = "2" ]]; then echo "This is elif"else echo "This is else"fiFormat current date and time in a nicelyecho "Recent logs are at logs_`date +%Y%m%d_%H%M%S`"Pipe both stderr and stdout to a filepython main.py 80 > logs_`date +%Y%m%d_%H%M%S` 2>&1 &

Install latest #nodejs on raspberry pi (#raspbian)


First add the source:curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -Install just like normal - don’t install node which is different.sudo apt install nodejsNow you can use it just like normal nodejs, this should output something like 7.blahnode -vNPM comes for free as well.npm -v

Solving pip error: ImportError: cannot import name IncompleteRead


$ sudo pip uninstall wheezyTraceback (most recent call last): File "/usr/bin/pip", line 9, in <module> load_entry_point('pip==1.5.6', 'console_scripts', 'pip')() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load ['__name__']) File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module> from pip.vcs import git, mercurial, subversion, bazaar # noqa File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module> from pip.download import path_to_url File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module> from requests.compat import IncompleteReadImportError: cannot import name IncompleteReadJust re-inst...

Complete Guide of Battle.net OAuth API and Login Button


I play Overwatch like crazy and I use sites like overbuff and masteroverwatch.I like their battle.net login buttons and wanted to create a simple site to beat matchmaking system. I didn’t realize that this will be a huge struggle.Here are the official docs:https://dev.battle.net/docs/read/oauthGet this Chrome Extension to try get post requests, amazing extension including authentication features:https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=enSign up first Go to the https://dev.battle.net and create a mashery account. Create your first app You can put localhost as callback url, you MUST put it as https://localhost https is really important let’s keep this in mind. Note your client key and secret and redirect_uri which must be an HTTPS url.Get authorization codeOauth is usually 2-steps. First you authorize the user and then use this authorization to obtain an access token in order to make requests to battle.net on behalf ...

Simplest Raspberry Pi 3 setup as a home server - Jan'17


I’ve just done it and I don’t want to forget this struggle. Buy a super fast 32 gb sd card - keep your adapter because most of the new computers only have sd card slots not micro sd slots. Format sd card as FAT - MSDOS with Disk utility -> Erase on Mac Right click -> Format on Windows Disks on Ubuntu Download NOOBS - easy UI to select which OS should be installed into your pi. Don’t bother flashing yourself with raspbian etc. Extract NOOBS zip and copy all of the files (if it’s extracted into a folder just copy its content, root of the sd card must have a couple of files, not one directory) Put your recently formatted and NOOBs copied sd card into the pi and then wait a little bit Plug your raspberry pi into micro usb Plug your monitor via an HDMI cable Plug your mouse and keyboard (mechanical keyboards take some time though to be recognized, just wait a little bit more) NOOBS UI will show up, for raspberry pi 3 you can connect to wifi. You ca...

Enable SSH access to your fresh Ubuntu install (16.10)


Leaving this here since I should not spend another hour to figure this out in my next fresh ubuntu install.Install ssh server first:sudo apt-get install openssh-server And open the port:sudo ufw allow 22Find your IP addressifconfig

My site is hacked with an interesting method


I have a small Turkish meme site. It’s very simple and easy to maintain.I use cloudflare for caching, SSL and DNS stuff and I love it.However, today I realized that my site started to redirect to some weird site which says some random “Your flash is outdated, please update”. Check chrome network tab - can not see anything because it’s a redirect and all info is gone. Check domain provider - all good Check Cloudflare DNS settings - all goodLast resort I tried to find out the HTTP request call tree.I’m breaking the redirection URL because I don’t want to send them traffic.curl --head guldum.netHTTP/1.1 301 Moved PermanentlyDate: Thu, 19 Jan 2017 17:24:22 GMTConnection: keep-aliveSet-Cookie: __cfduid=d0af6e03ce78a3a99580dc2bbc87c90c31484846662; expires=Fri, 19-Jan-18 17:24:22 GMT; path=/; domain=.guldum.net; HttpOnlyLocation: https://goo.gl/ H41yAyServer: cloudflare-nginxCF-RAY: 323bfadaa6ec3470-LHRIt has a 301 redirection, it immediately popped up in my mind: Page rules. I checked ...


subscribe via RSS