Skip to content

Instantly share code, notes, and snippets.

View dweeber's full-sized avatar

Kevin Reed dweeber

  • TNET Services Inc
  • Mesa AZ
View GitHub Profile
@dweeber
dweeber / gist:4055331
Created November 11, 2012 15:58
Set RPI hostname based on /boot/serial_hostname.txt file
#! /bin/sh
### BEGIN INIT INFO
# Provides: serial_hostname
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before hostname
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Set hostname based on /boot/serial_hostname.txt
# Description: Read the machines hostname from /boot/serial_hostname.txt,
@dweeber
dweeber / anewhost.sh
Created November 2, 2012 01:40
Script to change /etc/hosts and /etc/hostname if /boot/newhost is found
#! /bin/sh
### BEGIN INIT INFO
# Provides: anewhost.sh
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start: S
# Default-Stop:
# Short-Description: Changes /etc/hostname /etc/hosts if /boot/newhost found
# Description: /boot/newhost file to change the
@dweeber
dweeber / hostname.sh
Created November 1, 2012 11:19
Replacement /etc/init.d/hostname.sh to provide for auto changing hosts hostname
#! /bin/sh
### BEGIN INIT INFO
# Provides: hostname
# Required-Start:
# Required-Stop:
# Should-Start: glibc
# Default-Start: S
# Default-Stop:
# Short-Description: Set hostname based on /etc/hostname
# Description: Read the machines hostname from /etc/hostname, and
@dweeber
dweeber / phonehome.php
Created October 26, 2012 22:54
Phone Home Script
<?php
######################################################################
# Phonehome script to obtain IP of home router
#
# Call with wget from your internal machine
# with the command:
# wget -t 10 http://yourwebsite/phonehome.php?c=1234&cmd=1 -O /dev/null
#
######################################################################
$SY = array();
@dweeber
dweeber / gist:3950942
Created October 25, 2012 06:53
Script to check for button press
#!/bin/bash
#################################################
# Switch Test #1
#
# Sets up the GPIO 4 port to check for a button
# press. Loops until the button is pressed
#
# Ref:
# http://rpi.tnet.com/project/hardware/project001
#
@dweeber
dweeber / gpio.c
Created October 21, 2012 21:06
Original gpio.c module
/*
* gpio.c:
* Swiss-Army-Knife, Set-UID command-line interface to the Raspberry
* Pi's GPIO.
* Copyright (c) 2012 Gordon Henderson
***********************************************************************
* This file is part of wiringPi:
* https://projects.drogon.net/raspberry-pi/wiringpi/
*
* wiringPi is free software: you can redistribute it and/or modify
@dweeber
dweeber / gist:3807857
Created September 30, 2012 17:42
Init.d script for tightvnc
#!/bin/sh
### BEGIN INIT INFO
# Provides: tightvncserver
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start vnc server
# Description:
### END INIT INFO
@dweeber
dweeber / gist:3748975
Created September 19, 2012 10:49
Bash script uses vcgencmd on Raspberry Pi with bc to calculate F value of Temp
#!/bin/bash
######################################################################
# Raspberry Pi
#
# Gross Script by Dweeber (Kevin Reed) <dweeber.dweebs@gmail.com>
# V1.0 2012-09-19
#
# Use the vcgencmd to obtain the Temp of the SOC
# then calculates the F value using bc.
#
@dweeber
dweeber / menu
Created September 18, 2012 20:13
Simple menu of common things located in /usr/local/bin/menu
echo
echo Menu of Common Things
echo ===============================================================================
cat <<EOF
Omxplayer .................. omxplayer -o hdmi filename.mp4
Locations of Stuff ......... locations
Turn On VNC server ......... vncserver :1 -geometry 1280x800 -depth 24
Switch to Videos ........... vidoes
Switch to /etc/network ..... networks
Status of Stuff ............ status
@dweeber
dweeber / sample code
Created September 9, 2012 18:34
Sample code of determining the size of the partition.
DISK_SIZE="4" # set this to the card size in nominal GB
# or: DISK_SIZE="$(($(sudo blockdev --getsz /dev/mmcblk0)/2048/925))"
PART_START="$(sudo parted /dev/mmcblk0 -ms unit s p |grep "^2" |cut -f2 -d:)"
[ "$PART_START" ] || exit 1
PART_END="$((DISK_SIZE*925*2048-1))"
[ "$PART_END" -ge 3788799 ] || exit 1
printf "d\n2\nn\np\n2\n$PART_START\n$PART_END\np\nw\n" |sudo fdisk /dev/mmcblk0