Flashing TinkerOS onto your sd card from MacOS

The main landing page for the Tinker Board only provides instructions for Window and Linux. And at this point the Linux zip they provide for you to download is corrupt or just refuses to unzip on MacOS. Anyways, heres the steps I took to get my card flashed and ready to go.

  1. Download TinkerOS 1.4 (or latest) from here
  2. Unzip:
    unzip 20170223-tinker-board-linaro-jessie-alip-v14.zip
  3. Insert micro sd card into macbook via adapter
  4. Open disk utility and ensure sd card is formatted as FAT 32
  5. Take note of the device, in my case disk2s1, but we just need to know that it’s disk2
  6. Unmount the card via disk utility
  7. Image card:
    sudo dd if=/Users/anthony/Desktop/20170223-tinker-board-linaro-jessie-alip-v14.img of=/dev/rdisk2 bs=1m
  8. Took about 70 seconds to compete the dd command
  9. Plug into Tinker Board and tinker away

Automating WordPress updates with cron and the wp-cli

Ain’t nobody got time to worry about updates. I’d rather have it break while updating than have it hacked by a script kiddie because I’ve neglected to login for a while. We will see if this ever breaks anything.

Install WordPress-CLI if you have not already.

Add all your sites to the update_wp.sh script:

#!/bin/bash
declare -a arr=(
  "anthonypenner.com" 
  "trekcamp.org"
  "etc"
)

for i in "${arr[@]}"
do
  echo $i
  cd /usr/share/nginx/html/$i
  sudo -u nobody wp core update
done

NOTE: Substitute /usr/share/nginx/html for the directory that holds your WordPress sites. Change user nobody to the user that owns the aforementioned directories. Check with ls -al, it might be the user that apache/nginx runs as, check that with top, htop, or ps -aux

Make sure it’s executable:

chmod +x update_wp.sh

Run the script daily and live dangerously!

30 2 * * * bash /home/anthony/update_wp.sh >/dev/null 2>&1

Linux schedule a one off reboot or task

So the server requires a reboot because you updated the kernel but clients are using it and you don’t work at 1:00am? Not a problem…

echo "/sbin/shutdown -r now" |at 01:00 tomorrow

You can also the check the queued jobs with:

atq

job 15 at Wed May  6 04:00:00 2015

And you can cancel the job like so:

at -r jobid

Or you can delete all jobs with:

atrm $(atq | cut -f1)

And as always RTFM

Linux Backlight for CM Storm Devastator Keyboard

The CM Storm keyboard was dirt cheap and looks really cool. The only problem is that on Fedora 21 and other Linux distributions the Scroll Lock key is not enabled by default. And it just happens to be the key that toggles the keyboard backlight. I don’t know why they didn’t just put a switch on the keyboard.

For Fedora 21:

Install A keyboard binding tool

yum install xdotool

Add an easy alias to toggle the backlight from the command line with the ‘k’ key

vim ~/.bashrc

alias k="xmodmap -e 'add mod3 = Scroll_Lock' && xdotool key --delay 10 'Scroll_Lock'"

Even better than that, lets trigger the toggle command on login. This part is Gnome specific and wont work on Ubuntu (Unless you removed Unity)!

vim ~/.bash_profile

dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | ( while true; do read X; if echo $X | grep "boolean true" &> /dev/null;then :; elif echo $X | grep "boolean false" &> /dev/null; then sh /home/penner/scripts/keyboard.sh; fi done ) &

vim /home/penner/scripts

#!/bin/bash/keyboard.sh

xmodmap -e "add mod3 = Scroll_Lock"
xdotool key --delay 10000 "Scroll_Lock"

You need to adjust the script paths for yourself. Might want to tweak the time outs as well. Good luck.