{"id":16,"date":"2007-07-29T19:28:00","date_gmt":"2007-07-29T19:28:00","guid":{"rendered":"http:\/\/www.mohanjith.net\/wordpress\/?p=16"},"modified":"2007-07-29T19:28:00","modified_gmt":"2007-07-29T19:28:00","slug":"svnserve-init-script","status":"publish","type":"post","link":"https:\/\/mohanjith.net\/blog\/2007\/07\/svnserve-init-script.html","title":{"rendered":"svnserve Init script"},"content":{"rendered":"<p>I was annoyed to have to start the svnserve as a daemon everytime I restarted the machine. I also wanted to use service configuration(GNOME) to deal with the service.<\/p>\n<p>I looked all over the web and failed to find the a good one. So I thought of writing it my self. Last weekend I sat down and wrote the script. <a href=\"http:\/\/www.mohanjith.net\/downloads\/svn\/etc\/init.d\/svnserve\">Here<\/a> is the result.<\/p>\n<p>This was tested on fc6 running kernel 2.6.20-1.2962.fc6. Subversion 1.4.2  (subversion-1.4.2-2.fc6). It should work in any distro with init.<\/p>\n<p>To make service configuration aware of svn serve you will have to first copy the script to \/etc\/init.d and then run the following.<\/p>\n<p><code>$ \/sbin\/chkconfig ---add svnserve<\/code><\/p>\n<p>Also remember to create the configuration(\/etc\/sysconfig\/subversion) file with the following lines in it to enable threading.<\/p>\n<p><code>OPTIONS=\"--threads\"<\/code><\/p>\n<p>You can put any options you could send to svnserve in the configuration file.<\/p>\n<p>PS: here is the Init script it self for your viewing before downloading<\/p>\n<p><code>#!\/bin\/bash<br \/>#<br \/>#   \/etc\/rc.d\/init.d\/subversion<br \/>#<br \/># Starts the Subversion Daemon<br \/>#<br \/># chkconfig: 2345 90 10<br \/># description: Subversion Daemon<br \/># processname: svnserve<br \/># pidfile: \/var\/lock\/subsys\/svnserve<\/p>\n<p>source \/etc\/rc.d\/init.d\/functions<\/p>\n<p>[ -x \/usr\/bin\/svnserve ] || exit 1<\/p>\n<p>### Default variables<br \/>SYSCONFIG=\"\/etc\/sysconfig\/subversion\"<\/p>\n<p>### Read configuration<br \/>[ -r \"$SYSCONFIG\" ] &&amp; source \"$SYSCONFIG\"<\/p>\n<p>RETVAL=0<br \/>prog=\"svnserve\"<br \/>desc=\"Subversion Daemon\"<br \/>pidfile=\"\/var\/run\/$prog.pid\"<\/p>\n<p>start() {<br \/>echo -n $\"Starting $desc ($prog): \"<br \/>daemon $prog -d $OPTIONS --pid-file $pidfile<br \/>RETVAL=$?<br \/>if [ $RETVAL -eq 0 ]; then<br \/>  touch \/var\/lock\/subsys\/$prog<br \/>fi<br \/>echo<br \/>}<\/p>\n<p>obtainpid() {<br \/>pidstr=`pgrep $prog`<br \/>pidcount=`awk -v name=\"$pidstr\" 'BEGIN{split(name,a,\" \"); print length(a)}'`<br \/>if [ ! -r \"$pidfile\" ] &&amp;amp;amp; [ $pidcount -ge 2 ]; then<br \/>pid=`awk -v name=\"$pidstr\" 'BEGIN{split(name,a,\" \"); print a[1]}'`<br \/>echo $prog is already running and it was not started by the init script.<br \/>fi<br \/>}<\/p>\n<p>stop() {<br \/>echo -n $\"Shutting down $desc ($prog): \"<br \/>if [ -r \"$pidfile\" ]; then<br \/>pid=`cat $pidfile`<br \/>kill -s 3 $pid<br \/>RETVAL=$?<br \/>else<br \/>RETVAL=1<br \/>fi<br \/>[ $RETVAL -eq 0 ] &&amp; success || failure<br \/>echo<br \/>if [ $RETVAL -eq 0 ]; then<br \/>  rm -f \/var\/lock\/subsys\/$prog<br \/>  rm -f $pidfile<br \/>fi<br \/>return $RETVAL<br \/>}<\/p>\n<p>restart() {<br \/>stop<br \/>start<br \/>}<\/p>\n<p>forcestop() {<br \/>echo -n $\"Shutting down $desc ($prog): \"<\/p>\n<p>kill -s 3 $pid<br \/>RETVAL=$?<br \/>[ $RETVAL -eq 0 ] &&amp; success || failure<br \/>echo<br \/>if [ $RETVAL -eq 0 ]; then<br \/>  rm -f \/var\/lock\/subsys\/$prog<br \/>  rm -f $pidfile<br \/>fi<\/p>\n<p>return $RETVAL<br \/>}<\/p>\n<p>status() {<br \/>if [ -r \"$pidfile\" ]; then<br \/>pid=`cat $pidfile`<br \/>fi<br \/>if [ $pid ]; then<br \/>        echo \"$prog (pid $pid) is running...\"<br \/>else<br \/>     echo \"$prog is stopped\"<br \/>fi<br \/>}<\/p>\n<p>obtainpid<\/p>\n<p>case \"$1\" in<br \/>start)<br \/>start<br \/>;;<br \/>stop)<br \/>stop<br \/>;;<br \/>restart)<br \/>restart<br \/>RETVAL=$?<br \/>;;<br \/>condrestart)<br \/>[ -e \/var\/lock\/subsys\/$prog ] &&amp; restart<br \/>RETVAL=$?<br \/>;;<br \/>status)<br \/>status<br \/>;;<br \/>forcestop)<br \/>forcestop<br \/>;;<br \/>*)<br \/>echo $\"Usage: $0 {start|stop|forcestop|restart|condrestart|status}\"<br \/>RETVAL=1<br \/>esac<\/p>\n<p>exit $RETVAL<\/code><\/p>\n<div id=\"fb-like\" style=\"\"><iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=https:\/\/mohanjith.net\/blog\/2007\/07\/svnserve-init-script.html&amp;layout=standard&amp;show_faces=true&amp;width=300&amp;action=like&amp;font=&amp;colorscheme=light&amp;locale=en_US\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:300px; height:30px\"><\/iframe><\/div>","protected":false},"excerpt":{"rendered":"<p>I was annoyed to have to start the svnserve as a daemon everytime I restarted the machine. I also wanted to use service configuration(GNOME) to deal with the service. I looked all over the web and failed to find the a good one. So I thought of writing it my self. Last weekend I sat &#8230; <a title=\"svnserve Init script\" class=\"read-more\" href=\"https:\/\/mohanjith.net\/blog\/2007\/07\/svnserve-init-script.html\" aria-label=\"More on svnserve Init script\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[19,49,26,51,50,52],"tags":[331,361,338,363,362,364],"class_list":["post-16","post","type-post","status-publish","format-standard","hentry","category-gnome","category-init","category-linux","category-shell","category-subversion","category-svn","tag-gnome","tag-init","tag-linux","tag-shell","tag-subversion","tag-svn"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5lUHm-g","jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/mohanjith.net\/blog\/wp-json\/wp\/v2\/posts\/16","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mohanjith.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohanjith.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohanjith.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohanjith.net\/blog\/wp-json\/wp\/v2\/comments?post=16"}],"version-history":[{"count":1,"href":"https:\/\/mohanjith.net\/blog\/wp-json\/wp\/v2\/posts\/16\/revisions"}],"predecessor-version":[{"id":188,"href":"https:\/\/mohanjith.net\/blog\/wp-json\/wp\/v2\/posts\/16\/revisions\/188"}],"wp:attachment":[{"href":"https:\/\/mohanjith.net\/blog\/wp-json\/wp\/v2\/media?parent=16"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohanjith.net\/blog\/wp-json\/wp\/v2\/categories?post=16"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohanjith.net\/blog\/wp-json\/wp\/v2\/tags?post=16"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}