dryder
June 10th, 2013, 01:38 PM
Hi
12.04 classic AMD64
I have a script called change-backgrounds - it works if I use it manually (even when run from /etc/init.d).
I placed it in /etc/init.d with a link to it in /etc/rc1.d. In /etc/rc1.d prefixed with K15: K15change-backgrounds as I want it to run on shutdown.
My problem is ether:
it does not run on shutdown
or the file containing the counter (/usr/share/backgrounds/contest/c.txt) is not written to.
I don't pretend it's the most elegant script - I'll concentrate on improving how it could be written later. For now, I just want it to run on shutdown.
#!/bin/bash
##
# count=$(</home/david/bash-scripts/c.txt)
count=$(</usr/share/backgrounds/contest/c.txt)
#
# echo $count
# read -p "pause ..." nothing
#
if [ $count -eq 1 ]
then
cp /usr/share/backgrounds/contest/space.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count = 2 ]
then
cp /usr/share/backgrounds/contest/karmic.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 3 ]
then
cp /usr/share/backgrounds/contest/lucid.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 4 ]
then
cp /usr/share/backgrounds/contest/maverick.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 5 ]
then
cp /usr/share/backgrounds/contest/natty.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 6 ]
then
cp /usr/share/backgrounds/contest/oneiric.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 7 ]
then
cp /usr/share/backgrounds/contest/precise-backup.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 8 ]
then
cp /usr/share/backgrounds/contest/quantal.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 9 ]
then
cp /usr/share/backgrounds/contest/raring.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 9 ]
then
count=0
fi
##
# NOW INCREASE COUNT
count=$((count+1))
##
# AND WRITE TO FILE
# echo $count > /home/david/bash-scripts/c.txt
echo $count > /usr/share/backgrounds/contest/c.txt
#
#
The count file (/usr/share/backgrounds/contest/c.txt) only updates if I run it manually.
Advice welcome - thanks
12.04 classic AMD64
I have a script called change-backgrounds - it works if I use it manually (even when run from /etc/init.d).
I placed it in /etc/init.d with a link to it in /etc/rc1.d. In /etc/rc1.d prefixed with K15: K15change-backgrounds as I want it to run on shutdown.
My problem is ether:
it does not run on shutdown
or the file containing the counter (/usr/share/backgrounds/contest/c.txt) is not written to.
I don't pretend it's the most elegant script - I'll concentrate on improving how it could be written later. For now, I just want it to run on shutdown.
#!/bin/bash
##
# count=$(</home/david/bash-scripts/c.txt)
count=$(</usr/share/backgrounds/contest/c.txt)
#
# echo $count
# read -p "pause ..." nothing
#
if [ $count -eq 1 ]
then
cp /usr/share/backgrounds/contest/space.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count = 2 ]
then
cp /usr/share/backgrounds/contest/karmic.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 3 ]
then
cp /usr/share/backgrounds/contest/lucid.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 4 ]
then
cp /usr/share/backgrounds/contest/maverick.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 5 ]
then
cp /usr/share/backgrounds/contest/natty.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 6 ]
then
cp /usr/share/backgrounds/contest/oneiric.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 7 ]
then
cp /usr/share/backgrounds/contest/precise-backup.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 8 ]
then
cp /usr/share/backgrounds/contest/quantal.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 9 ]
then
cp /usr/share/backgrounds/contest/raring.xml /usr/share/backgrounds/contest/precise.xml
fi
#
if [ $count -eq 9 ]
then
count=0
fi
##
# NOW INCREASE COUNT
count=$((count+1))
##
# AND WRITE TO FILE
# echo $count > /home/david/bash-scripts/c.txt
echo $count > /usr/share/backgrounds/contest/c.txt
#
#
The count file (/usr/share/backgrounds/contest/c.txt) only updates if I run it manually.
Advice welcome - thanks