..continued.
Create a log rotate script..
/etc/logrotate.d/lms:
Code:
--------------------
/var/log/lms/server.log {
weekly
rotate 5
size 200k
compress
missingok
postrotate
# send USR1 to squeezebox PID to reset logging
/bin/kill -USR1 `pgrep -f 'perl.*slimserver.pl' -n 2>/dev/null` 2>/dev/null
|| :
endscript
}
/var/log/lms/scanner.log {
weekly
rotate 5
size 200k
compress
missingok
}
--------------------
Create service control links:
Code:
--------------------
update-rc.d -f lms remove >/dev/null 2>&1
update-rc.d -f lms defaults
--------------------
Create a branch switching script:
/usr/local/sbin/lms-switch-branch.sh
Code:
--------------------
#!/bin/sh
NEWBRANCH='7.8'
ISGOODBRANCH=0
#Discard local changes...
DISCARD=0
#Update repo
UPDATE=0
if [ ! -z "$1" ]; then
NEWBRANCH="$1"
fi
# Change to the repo dir..
cd /usr/share/lms/server
# Get a list of the available branches..
BRANCHES=`git branch -r | sed -n -e 's#^.*origin/\(.*\)$#\1#p'`
for BRANCH in $BRANCHES
do
if [ "$NEWBRANCH" = "$BRANCH" ]; then
ISGOODBRANCH=1
fi
done
if [ $ISGOODBRANCH -lt 1 ]; then
echo "Error: ${NEWBRANCH} is not a branch of
github.com/Logitech/slimserver.git"
echo "Available branches:"
echo $BRANCHES
exit 1
fi
# Stop the service..
service lms stop
# Do a hard reset of the repo to discard any local changes..
if [ $DISCARD -gt 0 ]; then
git reset --hard
git clean -fd
fi
# Switch to the new branch
git checkout "$NEWBRANCH"
if [ $? -gt 0 ]; then
echo "Error checking out branch ${NEWBRANCH}."
exit 1
fi
# Update the default file with the name of the new branch
RE="s/^SLIMDESC=.*$/SLIMDESC='LMS branch ${NEWBRANCH} git code'"
sed -i -e "$RE" /etc/default/lms
# Update the repo
if [ $UPDATE -gt 0 ]; then
git pull
fi
# Create new data & log dirs..
LIBDIR="/var/lib/lms_data/${NEWBRANCH}"
LOGDIR="/var/log/lms_log/${NEWBRANCH}"
if [ ! -d "$LIBDIR" ]; then
mkdir -p "$LIBDIR"
fi
if [ ! -d "$LOGDIR" ]; then
mkdir -p "$LOGDIR"
fi
# Fix permissions
chown -r lms:nogroup "$LIBDIR"
chown -r lms:nogroup "$LOGDIR"
# Create new data & log links
LIBDIRLINK='/var/lib/lms'
LOGDIRLINK='/var/log/lms'
if [ -L "$LIBDIRLINK" ]; then
rm "$LIBDIRLINK"
fi
if [ ! -d "$LIBDIRLINK" ]; then
ln -s "$LIBDIR" "$LIBDIRLINK"
fi
if [ -L "$LOGDIRLINK" ]; then
rm "$LOGDIRLINK"
fi
if [ ! -d "$LOGDIRLINK" ]; then
ln -s "$LOGDIR" "$LOGDIRLINK"
fi
# Restart the service..
service lms start
exit $?
--------------------
Script for running the git code from the console in debug mode:
lms-git-debug.sh
Code:
--------------------
#!/bin/bash
# Script to debug running of lms git code..
#RUNASROOT=1
RUNASROOT=0
INSTNAME='lms'
INSTUSER='lms'
PIDFILE=/var/lib/${INSTNAME}/${INSTNAME}.pid
PREFSDIR=/var/lib/${INSTNAME}/prefs
LOGDIR=/var/log/${INSTNAME}
CACHEDIR=/var/lib/${INSTNAME}/cache
PUSER=${INSTUSER}
PGROUP=`id -ng $PUSER`
OUTFILE=./${INSTNAME}-git-debug.txt
if [ -e ${PIDFILE} ]; then
rm ${PIDFILE}
fi
echo "Attempting to start ${INSTNAME}.."
echo " Console output redirected to ${OUTFILE}.."
echo " Hit CTRL+C to terminate.."
if [[ $RUNASROOT -eq 1 ]]; then
/usr/bin/perl /usr/share/${INSTNAME}/server/slimserver.pl
--pidfile=${PIDFILE} --user=${PUSER} --group=${PGROUP} --cachedir=${CACHEDIR}
--prefsdir=${PREFSDIR} --logdir=${LOGDIR} --charset=utf8 --diag --d_startup
>${OUTFILE} 2>&1
else
sudo -u ${INSTUSER} /usr/bin/perl /usr/share/${INSTNAME}/server/slimserver.pl
--pidfile=${PIDFILE} --cachedir=${CACHEDIR} --prefsdir=${PREFSDIR}
--logdir=${LOGDIR} --charset=utf8 --diag --d_startup >${OUTFILE} 2>&1
fi
rm ${PIDFILE}
echo "Done! Examine ${OUTFILE} for details.."
--------------------
That's it for now. Mostly, I'm looking for comments here on the
advisability of this approach.
------------------------------------------------------------------------
gharris999's Profile: http://forums.slimdevices.com/member.php?userid=115
View this thread: http://forums.slimdevices.com/showthread.php?t=95169
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix