Auto delete Subversion repository and ViewVC viewvc.conf entries

From Joe's Boredom
Revision as of 03:14, 2 January 2010 by Joe (talk | contribs) (Protected "Auto delete Subversion repository and ViewVC viewvc.conf entries" ([edit=sysop] (indefinite) [move=sysop] (indefinite)))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

What it does

The following bash script will (using 'sudo')...

  • List off dirs in your svn root dir
  • Have you enter the dir you want to delete
  • Delete the dir
  • Display your ViewVC 'svn_roots =' string
  • Make a back-up of your current viewvc.conf
  • Have you enter what to delete from 'svn_roots =' string
  • Display your ViewVC 'root_parents =' string
  • Have you enter what to delete from 'root_parents =' string

Also see: Auto_create_new_Subversion_repository_and_New_entries_in_ViewVC_viewvc.conf

Walk through

When this script is run it will first list off all dirs in your Subversions main root dir

Terminal
name@machine:/$ 
****** SVN Repository List ******

... nautilus_scripts
... New_Repo_dir
... perl_Scripts

DELETE svn repository


Lets say you want to delete 'New_Repo_dir', the following will happen.

Terminal
name@machine:/$ 
DELETE svn repository

New_Repo_dir
[sudo] password for "ROOT":

- - - - - - - - - ViewVC svn_roots - - - - - - - - -
TestViewName : /all/mySubversion/New_Repo_dir , perlScripts: /all/mySubversion/perl_Scripts, nautilusScripts: /all/mySubversion/nautilus_scripts
- - - - - - - - - - - - - - - - - -
DELETE svn_roots =

Now you need to delete the ViewVC svn_roots Name and Path for New_Repo_dir, so copy/paste the following to your terminal

TestViewName : /all/mySubversion/New_Repo_dir ,

and the following will happen

Terminal
name@machine:/$ 
DELETE svn_roots =

TestViewName : /all/mySubversion/New_Repo_dir ,

- - - - - - - - - ViewVC root_parents - - - - - - - - -
/all/mySubversion : TestViewName , /all/mySubversion : perlScripts , /all/mySubversion : nautilusScripts
- - - - - - - - - - - - - - - - - -
DELETE root_parents =


And finally you have to delete ViewVC root_parents

/all/mySubversion : TestViewName ,
Terminal
name@machine:/$ 
DELETE root_parents =

/all/mySubversion : TestViewName ,


When deleting from ViewVC you have to be careful what you are doing.


The Script

Create a new file, svn_remove.sh
Make your newly created file executable

Terminal
name@machine:/$ sudo chmod +x /path/to/svn_remove.sh

Copy the code posted here to svn_remove.sh then save.
And the good'ol Disclaimer: This script worked for me and i hold no responsibility for what it does for you. <source lang="bash">

  1. !/bin/bash


  1. *** CONFIG SETTINGS - Change to reflect your environment ***
  2. path where 'viewvc' is installed

viewvc_config_path='/usr/local/viewvc-1.0.9';

  1. root path where Subversion saves its repositories

SVNpath='/all/mySubversion';

  1. *** END OF CONFIG ***


NOW=$(date +"%Y-%m-%d");

echo ; echo '****** SVN Repository List ******';

  1. List off all DIR's in SVN's root (for easy copy/paste at next promt);

ls -l "$SVNpath"; echo ;

  1. Enter the DIR of the repository which you want to delete

echo 'DELETE svn repository'; read RPOname;

  1. rm the dir

if $RPOname != ''  ; then sudo rm -R "$SVNpath/$RPOname"; fi

  1. Print "Subversion roots (repositories)" entry from viewvc.conf

viewvc=$(cat "$viewvc_config_path/viewvc.conf" | egrep '^svn_roots |/\#');

  1. clean the print alittle

viewvc=${viewvc/svn_roots = /}; viewvc=${viewvc/svn_roots =/}; viewvc=${viewvc/svn_roots= /}; viewvc=${viewvc/svn_roots=/}; echo '--------- ViewVC svn_roots ---------'; echo "$viewvc"; echo '------------------------------------';

  1. enter what you want to delete, MUST be exact

echo 'DELETE svn_roots ='; read viewvcname; echo ;

if $viewvcname != ''  ; then

viewvcname=${viewvcname//\//\\/}; viewvcname=${viewvcname//:/\\:};

# exit ViewVC cd "$viewvc_config_path"; sudo cp viewvc.conf viewvc.pre."$RPOname.$NOW";

sudo sed -i "s/$viewvcname//" viewvc.conf


# Print "Subversion root_parents (repositories)" entry from viewvc.conf viewvc=; viewvc=$(cat "$viewvc_config_path/viewvc.conf" | egrep '^root_parents |/\#'); viewvc=${viewvc/root_parents = /}; viewvc=${viewvc/root_parents =/}; viewvc=${viewvc/root_parents= /}; viewvc=${viewvc/root_parents=/}; echo '--------- ViewVC root_parents ---------'; echo "$viewvc"; echo '------------------------------------';

viewvcname=; # enter what you want to delete, MUST be exact echo 'DELETE root_parents ='; read viewvcname; echo ;

if $viewvcname != ''  ; then

viewvcname=${viewvcname//\//\\/}; viewvcname=${viewvcname//:/\\:};

# exit ViewVC #cd /usr/local/viewvc-1.0.9 sudo cp viewvc.conf viewvc.pre."$RPOname.$NOW" sudo sed -i "s/$viewvcname//" viewvc.conf fi

fi


exit;

</source>