#! /bin/sh
# /etc/init.d/rvid
# Carry out specific functions when asked to by the system
case "$1" in
start)
cd /etc/hildon-welcome.d/dconfs/
if [ -f 1.conf ]; then
# determine number of files in /dconfs
nof=$(ls *.conf | wc -l)
# get random number
rna=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")
rna=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")
if [ $rna -ge $rnb ]; then
let "rn = $rna - $rnb"
else
let "rn = $rnb - $rna"
fi
# in range of 1 - nof
let "rr = $rn % $nof + 1"
# choose random conf
rf="$rr.conf"
echo "$rr.conf"
# copy it over to default.conf
cp $rf ../default.conf
fi
;;
stop)
;;
*)
;;
esac
exit 0
chmod 755 /etc/init.d/rvid update-rc.d rvid defaults
| The Following User Says Thank You to b666m For This Useful Post: | ||
)

blablabla... same as in the code under this code.. blablabla
# get random number
rn=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")
blablabla... the same again... blablabla
start on starting shutdown
script
cd /etc/hildon-welcome.d/dconfs/
if [ -f 1.conf ]; then
# check which file is currently used
if [ -f *.lock ]; then
cuf=$(ls *.lock)
ruf=$cuf
rm *.lock
else
cuf="1.lock"
ruf=$cuf
fi
# determine number of files in /dconfs
nof=$(ls *.conf | wc -l)
while [ "$ruf" = "$cuf" ]; do
# get "random" number lol
rn=$(date +%s)
# in range of 1 - nof
let "rr = $rn % $nof + 1"
# choose random conf
ruf="$rr.lock"
rf="$rr.conf"
done
# set file for checking which file is in use
rb="$rr.lock"
# copy it over to default.conf
cp $rf ../default.conf
touch $rb
fi
end script
| The Following User Says Thank You to b666m For This Useful Post: | ||

