Is it just me, or is the forum search facility broken?

I'm pretty ignorant about Linux matters, so I'm wondering if there is a
much easier way to accomplish what I'm trying to do here.  My method
seems pretty primitive-Pete-ish to me.  Any comments or advice from any
of you Linux script-mavens would be greatly appreciated.

Anyway..I want to be able to reconfigure slimserver quickly to use one
of three different libraries using a script.  The libraries are:
'slimserverdata' which is my "production" library with real music and
real data; 'slimtestntfs' which is a test library of problematic files
on a ntfs drive mounted with ntfs-3g; 'simtestext2fs' which are
problematic files in a folder on the system drive.

I'm running the trunk code, so the preferences are stored in
/usr/local/slimserver_trunk/server/prefs/server.pref. I'm also running
a separate instance of MySQL and I've created schemas for each of the
libraries.

I need to change 3 entries in the server.pref file: the 'audiodir'
line, the 'dbsource' line and the 'playlistdir' line.

I assumed that I would use 'patch' to fixup server.prefs and that my
script would go something like this:

Code:
--------------------
    
  #!/bin/sh
  
  if [ ! -n "$1" ]
  then
  patchfile='slimserverdata'
  else
  patchfile=$1
  fi
  
  if [ ! -e /usr/local/slimserver_trunk/server/prefs/$patchfile.patch ]
  then
  echo $patchfile 'library does not exist!'
  exit 1
  fi
  
  pushd . >/dev/null
  cd /usr/local/slimserver_trunk/server/prefs
  service slimserver stop
  echo 'Changing slimserver data library to ' $patchfile
  patch -p0 -f -i $patchfile.patch >/dev/null
  service slimserver start
  popd >/dev/null
--------------------

I assume the patchfile will look something like this:

Code:
--------------------
    
  --- server.prefs
  +++ server.prefs
  @@ -660,7 +660,7 @@
  _version: 1
  allowedHosts: 127.0.0.1,192.168.0.*
  artfolder: ''
  -audiodir: /mnt/media/Music
  +audiodir: /slimtest/music
  authorize: 0
  bandInArtists: 0
  browseagelimit: 100
  @@ -674,7 +674,7 @@
  coverArt: ''
  csrfProtectionLevel: 1
  dbpassword: slimserver
  -dbsource: dbi:mysql:hostname=127.0.0.1;port=3306;database=slimserverdata
  +dbsource: dbi:mysql:hostname=127.0.0.1;port=3306;database=slimtestext2fs
  dbusername: slimserver
  disableStatistics: 1
  disabledextensionsaudio: ''
  @@ -702,7 +702,7 @@
  noupnp: 1
  password: ''
  persistPlaylists: 1
  -playlistdir: /mnt/media/Playlists
  +playlistdir: /slimtest/playlists
  playtrackalbum: 1
  rank-PLUGIN_PICKS_MODULE_NAME: 4
  refreshRate: 60 
--------------------

My problem is that the "change from" data on the lines in question is
unknown.  The server.prefs file could be configured for any of the
three libraries.  I've managed to make this work by using
'intermediate' patch files that change the 'audiodir', 'dbsource' and
'playlistdir' all to 'DUMMYDATA' and then patching again against that,
but that seems like a kludge to me.

Is there a way to make 'patch' "forgiving" about the "change from"
lines?  Or can anyone suggest an alternative approach (short of any
actual perl script) here?  Perhaps I ought to be using some combination
of echo, cat, grep magic to produce the appropriate patch file on the
fly?


-- 
gharris999
------------------------------------------------------------------------
gharris999's Profile: http://forums.slimdevices.com/member.php?userid=115
View this thread: http://forums.slimdevices.com/showthread.php?t=36606

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/unix

Reply via email to