Auto delete Subversion repository and ViewVC viewvc.conf entries
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 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 - - - - - - - - - ViewVC 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 - - - - - - - - - |
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">
- !/bin/bash
- *** CONFIG SETTINGS - Change to reflect your environment ***
- path where 'viewvc' is installed
viewvc_config_path='/usr/local/viewvc-1.0.9';
- root path where Subversion saves its repositories
SVNpath='/all/mySubversion';
- *** END OF CONFIG ***
NOW=$(date +"%Y-%m-%d");
echo ; echo '****** SVN Repository List ******';
- List off all DIR's in SVN's root (for easy copy/paste at next promt);
ls -l "$SVNpath"; echo ;
- Enter the DIR of the repository which you want to delete
echo 'DELETE svn repository'; read RPOname;
- rm the dir
if $RPOname != '' ; then sudo rm -R "$SVNpath/$RPOname"; fi
- Print "Subversion roots (repositories)" entry from viewvc.conf
viewvc=$(cat "$viewvc_config_path/viewvc.conf" | egrep '^svn_roots |/\#');
- 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 '------------------------------------';
- 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>