Skip to content

Instantly share code, notes, and snippets.

@jhenkens
Last active August 29, 2015 14:01
Show Gist options
  • Save jhenkens/b7ac850780fc249df27b to your computer and use it in GitHub Desktop.
Save jhenkens/b7ac850780fc249df27b to your computer and use it in GitHub Desktop.
OpenElec Files
#!/bin/bash
# OpenElec Power Script to restart XBMC
# I didn't want to bind any special buttons to reboot xbmc, and I already had a button to sleep cycle the box.
# I wrote this script to kill xbmc within OpenElec if you sleep and then wake within 60 secodns
# Put it in /storage/.config/sleep.d/01-autoreboot
# Or whatever you want within sleep.d, autoreboot is a terrible name
LOCDIR=/storage/.config/.autoreboot
mkdir -p "$LOCDIR"
LOC="$LOCDIR"/timestamp
TIME=`date +%s`
case "$1" in
post)
if [ -f "$LOC" ] ; then
OLDTIME=`cat "$LOC"`
DIFF=$((TIME-OLDTIME))
DIFF=${DIFF#-}
if [ $DIFF -lt "60" ]; then
killall -HUP xbmc.bin
fi
fi
;;
pre)
echo $TIME > "$LOC"
;;
esac
#!/bin/sh
# this is my autostart script for OpenElec
# It mounts a Samba share 'Pictures' at 'server.lan' after making sure that the server is up (well, to the best of its abilities)
# This is useful for things that need to be accessed directly rather than through xbmc's file handlers.
# It also removes that damn sleep disabler from OpneElec 4.0.0+ for removable media
# I use openelec as a thin client to content stored on a server, I don't need my storage to be safe/reliable on my sd card!
set -x
rm -f /dev/.suspend_disabled
n=1
server="server.lan"
shares="Pictures"
sambapass="test"
sambauser="test"
# can be nfs for nfs or cifs for samba or windows shares
type=cifs
until ping -w 1 -c 1 "$server" &>/dev/null ;do
sleep 1
n=$(( n+1 ))
[ $n -eq 30 ] && break
done
for share in $shares ;do
[ -d /media/$share ] || mkdir -p /media/$share
if [ $type == cifs ];then
mount -t $type -o username=$sambauser,password=$sambapass,rw //$server/$share /media/$share
elif [ $type == nfs ];then
mount -t $type $server:/$share /media/$share
fi
done
ln -sf /media /storage/media
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment