22dda [Solved] Services stop when upgrading ports? - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Ports & Packages > Installation and Maintenance of FreeBSD Ports or Packages

Installation and Maintenance of FreeBSD Ports or Packages Installing and maintaining the FreeBSD Ports Collection or FreeBSD Packages (i.e. third party software).

Reply
 
Thread Tools Display Modes
  #1  
Old October 2nd, 2009, 08:34
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default Services stop when upgrading ports?

One thing I have noticed when upgrading my ports is that after the upgrade is complete many services on my server have been stopped. Is this normal?

For instance, yesterday there were a couple ports that I upgraded and my Courier Authlib, Courier IMAP and SpamAssassin service was stopped.

Is this what happens when your ports are upgraded? Do I need to check ALL my services after upgrading my ports everytime?
Reply With Quote
  #2  
Old October 2nd, 2009, 09:07
SirDice's Avatar
SirDice SirDice is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 13,702
Thanks: 47
Thanked 2,022 Times in 1,861 Posts
Default

That's normal. If a package is removed, the service is stopped. When a package is installed it's not started automatically.
__________________
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
Reply With Quote
  #3  
Old October 2nd, 2009, 14:08
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default

Thank you!

I need to get into the habit of making sure all services are started after updating all my ports...
Reply With Quote
  #4  
Old October 2nd, 2009, 14:10
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,828
Thanks: 30
Thanked 1,887 Times in 1,332 Posts
Default

Not all ports behave in exactly the same way. E.g. dovecot will ask you whether to stop the service or not. MySQL on the other hand simply stops the service, without giving any feedback about it. So yes, always check.
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Adminstrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
  #5  
Old October 2nd, 2009, 14:14
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default

Yeah, I found that out the hard way! It stopped my authlib and IMAP services and people couldn't login to web mail anymore for a few hours. It had me puzzled until I went through the necessary logfiles...

Thanks for the advice.
Reply With Quote
  #6  
Old October 2nd, 2009, 14:22
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,828
Thanks: 30
Thanked 1,887 Times in 1,332 Posts
Default

Code:
for script in /usr/local/etc/rc.d/*
do
$script restart
done
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Adminstrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
  #7  
Old October 2nd, 2009, 14:24
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default

That looks helpful!

Do I just copy that into a file and run it after I have run the upgrade of the ports?
Reply With Quote
  #8  
Old October 2nd, 2009, 14:26
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,828
Thanks: 30
Thanked 1,887 Times in 1,332 Posts
Default

Sure! Might be better to fine-tune it a little instead of just restarting everything. Lemme work on that and get back to you here.
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Adminstrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---

Last edited by DutchDaemon; October 2nd, 2009 at 15:10.
Reply With Quote
  #9  
Old October 2nd, 2009, 14:27
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default

What if you just say start the services that are stopped:

Code:
for script in /usr/local/etc/rc.d/*
do
$script start
done
Or have I over simplified it?
Reply With Quote
  #10  
Old October 2nd, 2009, 14:40
dennylin93 dennylin93 is offline
Member
 
Join Date: Dec 2008
Posts: 784
Thanks: 34
Thanked 103 Times in 71 Posts
Default

Quote:
Originally Posted by DutchDaemon View Post
Sure! Might be better to fine-tune it a little insetad of just restarting everything. Lemme work on that and get back to you here.
It should only start the services that are enabled it /etc/rc.conf, so there shouldn't be a problem.
Reply With Quote
  #11  
Old October 2nd, 2009, 14:43
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,828
Thanks: 30
Thanked 1,887 Times in 1,332 Posts
Default

Code:
#!/bin/sh
for script in /usr/local/etc/rc.d/*; do if $script rcvar | grep -q "=[yY][eE][sS]" && \
$script status | grep -q 'not running'; then $script start; fi; done
This will only start services defined in /etc/rc.conf ("yes", "YES", combinations thereof) which are not running now. Ports-based services only, of course.
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Adminstrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---

Last edited by DutchDaemon; May 6th, 2012 at 01:41.
Reply With Quote
  #12  
Old October 2nd, 2009, 14:46
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default

Wow thanks! I'm glad you wrote that.

I created a file called restart and pasted everything into it but when I run it as follows:
Code:
./restart
It says: Permission denied (while I am logged in as root)
Reply With Quote
  #13  
Old October 2nd, 2009, 14:48
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,828
Thanks: 30
Thanked 1,887 Times in 1,332 Posts
Default

Make it executable (chmod 500 should suffice).
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Adminstrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
  #14  
Old October 2nd, 2009, 14:49
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default

Sorry blonde momoent, I had to run chmod 700 on it!

It works like a charm! I stopped my ClamAV service and it restarted it...thank YOU!!
Reply With Quote
  #15  
Old October 2nd, 2009, 14:54
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default

How do I put a comment in the script so I know what this script does for when I look at the code in the future?
Reply With Quote
  #16  
Old October 2nd, 2009, 14:56
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,828
Thanks: 30
Thanked 1,887 Times in 1,332 Posts
Default

Just put a line in there starting with '#' (without the quotes).
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Adminstrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
  #17  
Old October 2nd, 2009, 14:58
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default

Thats what I did and it says:
Code:
for: Command not found.
script: Undefined variable.
The script looks as follows now (I used your comments):
Code:
#This will only start services defined in /etc/rc.conf ("yes", "YES", combinations thereof)
#which are not running now. Ports-based services only, of course.
#!/bin/sh
for script in /usr/local/etc/rc.d/*; do if $script rcvar | grep -q "=[yY][eE][sS]" && $script status | grep -q 'not running'; then $script start; fi; done
Reply With Quote
  #18  
Old October 2nd, 2009, 15:01
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,828
Thanks: 30
Thanked 1,887 Times in 1,332 Posts
Default

Put those two comments at the bottom of the script. This looks like (t)csh. It may be a bit picky when it comes to the location of the hashbang (the magic '#!' invocation). Other shells care less, but I guess (t)csh wants it front and center, i.e. at the start of the first line.
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Adminstrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
  #19  
Old October 2nd, 2009, 15:08
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,828
Thanks: 30
Thanked 1,887 Times in 1,332 Posts
Default

Final note: not all rc.d scripts appear to have the 'status' command. E.g. I found this one:

Code:
/usr/local/etc/rc.d/mailman: unknown directive 'status'.
Usage: /usr/local/etc/rc.d/mailman [fast|force|one](start|stop|restart|rcvar|reload)
So if you ever encounter one of those you'll have to check it by hand. Of course, I could just make the script increasingly/eerily adaptive and over half a page long
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Adminstrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
  #20  
Old October 2nd, 2009, 16:48
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default

I moved the comments to the end and all worked like a charm.

I think you wrote an awesome script in only 2 lines...;-)
Reply With Quote
  #21  
Old October 2nd, 2009, 17:29
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Administrator
 
Join Date: Nov 2008
Location: Rotterdam, the Netherlands
Posts: 9,828
Thanks: 30
Thanked 1,887 Times in 1,332 Posts
Default

Cheers!
__________________
FreeBSD Forums: Information for New Members | FreeBSD Forums Rules
FreeBSD Resources: The FreeBSD Handbook | Manuals | FAQ | Wiki
Before you post: How to ask questions the smart way
If you must know .. So, what does an Adminstrator/Moderator do?
---> Do not PM me with FreeBSD questions. I do not work here. <---
Reply With Quote
The Following User Says Thank You to DutchDaemon For This Useful Post:
xy16644 (October 2nd, 2009)
  #22  
Old May 5th, 2012, 14:56
xy16644 xy16644 is offline
Member
 
Join Date: Jul 2009
Posts: 502
Thanks: 14
Thanked 7 Times in 3 Posts
Default

Sorry to open this thread up again but the script I have been using to restart services that have stopped due to a port being upgraded no longer works

I'm still running:
Code:
#!/bin/sh
for script in /usr/local/etc/rc.d/*; do if $script rcvar | grep -q "=[yY][eE][sS]" && \
$script status | grep -q 'not running'; then $script start; fi; done
But even after running this, I still find that there are services that are in a stopped state and I have to start them up manually.

What would have caused this script to stop working?

Last edited by DutchDaemon; May 6th, 2012 at 01:39.
Reply With Quote
  #23  
Old May 5th, 2012, 19:27
aa aa is offline
Junior Member
 
Join Date: Mar 2012
Posts: 47
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Quote:
Originally Posted by xy16644 View Post
What would have caused this script to stop working?
Could be anything. What services actually are they?
Try first to run those services in the correct order:
Code:
for script in `rcorder /usr/local/etc/rc.d/* 2>/dev/null`; do ..
Maybe they depend also on then stopped /etc/rc.d/* services?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] Upgrading packages without ports luckytaxi Installation and Maintenance of FreeBSD Ports or Packages 11 May 10th, 2010 18:34
stop xserver or stop compiz gulanito X.Org 3 August 3rd, 2009 11:00
Stop in /usr/ports/graphics/inkscape ericturgeon GNOME 1 February 28th, 2009 18:43
Upgrading ports in a jail diogenes Installing & Upgrading 3 February 13th, 2009 06:41
Upgrading ports with options sfatula Installation and Maintenance of FreeBSD Ports or Packages 2 January 22nd, 2009 23:17


All times are GMT +1. The time now is 06:00.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0