Page 3 of 10 FirstFirst 12345 ... LastLast
Results 21 to 30 of 96

Thread: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

  1. #21
    Join Date
    Sep 2007
    Beans
    75

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by asrock-z68 View Post
    Nice write up. I wish I had this when I was getting started. With Netatalk don't forget to add the "tm" option to the end of your AppleVolume.default for your shares. This will allow Apple Time Machine to recognize the share as Time Machine compatible. Also make sure your shares have read-write permissions.
    Sorry for the long absence everyone... things got busy at work, I'm, moving, and getting married in a couple of months. Much. To. Do.


    Anyway, thanks for the note. You are absolutely correct regarding the "tm" option and changing the read-write permissions on the shares. I will update the tutorial accordingly.

  2. #22
    Join Date
    Sep 2007
    Beans
    75

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by castlecloud View Post
    Thank you for the great tutorial.

    I followed along and when I tried to install the knockd software,
    apt-get couldn't download anything anymore.

    After a bit of searching I found that ufw needed another rule:

    sudo ufw allow out http

    which allows outgoing connections on port 80/tcp.

    Can you confirm that, or did I miss something?
    I don't think you missed anything. You may be right and we might need to add this rule. I thought I had done something specifically to allow apt to run through the firewall but I may not have (there was so much back and forth when I was building the server that it is possible that I turned on ufw after I had done all of my apt-gets).

    Most likely, if you got it to work using this rule then you should be ok. Especially since you are only allowing the outbound on port 80.

    Currently I am in the process of moving and the server is packed up and won't be unpacked for several weeks so I can't test this myself. That said, you are most likely correct and I will update the tutorial accordingly. Thanks for catching that.

  3. #23
    Join Date
    Sep 2007
    Beans
    75

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by jdawgvh View Post
    I've got this all up and running (although I do have a Ubuntu client instead of a Mac). I would like to make a small change. I want my server to automatically update itself. My concern is that I have the server checking every five minutes for activity on my network and it shuts itself down if it finds none. So if I fire up my laptop to grab a file that I forgot or something and then shut it right back down my server might not have time to complete all the updates. Is there a way to prevent the system from shutting down until updates are complete?
    As you noticed, the sleep script is incredibly stupid. Its only criteria for staying awake is whether a client is also awake.

    Ideally we would update the script so that it also looks for specific activities and as long as they are active, it will stay awake.

    The original script looked like this:

    Code:
    #! /bin/bash
    
    #check to see if any other devices are responding to pings
    #only check addresses 172.16.1.2 - 172.16.1.99 because
    #the Airport is always on address 172.16.1.1 and all of my
    #always on devices (that don't need server access) have
    #reserved IP address of 172.16.1.100 and above
    
    #if there are no responding clients in the ip range, go to sleep
    if [ `/usr/bin/fping -a -g 172.16.1.2 172.16.1.99 2> /dev/null | wc -l` -eq 0 ]; then
    	/usr/sbin/pm-hibernate
    fi

    what we want to do is edit so that it also looks for specific tasks that are running.

    Note, my server is currently packed away (I am moving) and won't be back up for a number of weeks. I cannot test the following code and I am pretty sure it won't work out of the box. But it is a start. Once I have some time I will try to make the change official (and test it) and post back here.

    Still, for now we want to edit the script so that it reads something like this:
    Code:
    #! /bin/bash
    
    #check to see if any other devices are responding to pings
    #only check addresses 172.16.1.2 - 172.16.1.99 because
    #the Airport is always on address 172.16.1.1 and all of my
    #always on devices (that don't need server access) have
    #reserved IP address of 172.16.1.100 and above
    
    #also check for specific tasks that may be running that we do not
    #want to interrupt
    
    #by default the server wants to go to sleep
    goToSleep=1
    
    #if there are responding clients in the ip range, stay awake
    if [ `/usr/bin/fping -a -g 172.16.1.2 172.16.1.99 2> /dev/null | wc -l` -gt 0 ]; then
            goToSleep=0
    fi
    
    
    #repeat the following block once for each process you want to keep the server awake for:
    
    #check for a specific running process
    if [ `/bin/ps aux | grep -i XXXXX | wc -l` -gt 1 ]; then
            goToSleep=0
    fi 
    
    #only go to sleep if all the tests above did not change the goToSleep variable.
    if [ $goToSleep -eq 1 ]; then
    	/usr/sbin/pm-hibernate
    fi

    Note: YOU WILL HAVE TO REPLACE THE XXXXX with some text that matches the text of the process you want to keep the server awake for. Alas I don't know exactly what that is at the moment, but if anyone out there wants to chime in that would be great. Otherwise, you might look into kicking off a download manually and using the:

    ps aux

    command to see if you can determine what the process name is that is running.

    Again, once I have some more time I can come back to this and see how I can make it more robust. Hope this helps.

  4. #24
    Join Date
    Mar 2012
    Beans
    59

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    A HUGE thank you for the best setup guide I've been able to find! It's well written and easy to follow for a complete n00b like me.

    You have a couple typos, in the hdd temp section, specifically sudo pico ~/hddtemp_montior.sh It was kind of a WTF moment for me since I was cutting and pasting and the bugger is hard to see. It also occurs in the sensors monitor section.In the sensors monitor section you also have a line, sudo chmod ugo+rwx ~/hddtemp_monitor.sh, that should be sudo chmod ugo+rwx ~/sensors_monitor.sh.

    Regarding the msmtp setup section I didn't want to use my "real" email account for the concerns you expressed so I used THESE INSTRUCTIONS and set it up to email my "real" email account through a throwaway Gmail account. That way nothing is compromised by having the password in the clear.

    Code:
    defaults
    tls on
    tls_starttls on
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
     
    account default
    host smtp.gmail.com
    port 587
    auth on
    user username(at)gmail.com
    password mypass
    from username(at)gmail.com
    logfile /var/log/msmtp.log
    I'm still trying to get the sensors_monitor script working, it doesn't do anything at all for me. And that's as far as I've gotten now.

    Again, thanks for a great howto.

  5. #25
    Join Date
    Sep 2007
    Beans
    75

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Quote Originally Posted by Bushflyr View Post
    A HUGE thank you for the best setup guide I've been able to find! It's well written and easy to follow for a complete n00b like me.
    Thanks! We n00bs gotta look out for each other



    Quote Originally Posted by Bushflyr View Post
    You have a couple typos, in the hdd temp section, specifically sudo pico ~/hddtemp_montior.sh It was kind of a WTF moment for me since I was cutting and pasting and the bugger is hard to see. It also occurs in the sensors monitor section.In the sensors monitor section you also have a line, sudo chmod ugo+rwx ~/hddtemp_monitor.sh, that should be sudo chmod ugo+rwx ~/sensors_monitor.sh[FONT=Courier New][COLOR=RoyalBlue].[COLOR=Black][FONT=Arial]
    Thanks. Great catch. I've updated the post to fix those.

    Quote Originally Posted by Bushflyr View Post
    Regarding the msmtp setup section I didn't want to use my "real" email account for the concerns you expressed so I used THESE INSTRUCTIONS and set it up to email my "real" email account through a throwaway Gmail account. That way nothing is compromised by having the password in the clear.
    Great idea. I think I will do the same. I added a link to your comment up in the original post so that others can profit your insight as well.


    Quote Originally Posted by Bushflyr View Post
    I'm still trying to get the sensors_monitor script working, it doesn't do anything at all for me.
    When you say it does not do anything, does it kick out an error? If you set the temp to 1 degree, I am assuming it does not shut down the server, right? Did the steps above that section work? I.e. when you type:

    sudo sensors

    does it spit out any information?

    I'm trying to figure out if maybe lm-sensors is not working on your machine or if there is a problem with the script that I wrote that is calling it.

  6. #26
    Join Date
    Mar 2012
    Beans
    59

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    The sensors package seems to be working fine. Here's the output:

    Code:
    ****@****:~$ sudo sensors
    acpitz-virtual-0
    Adapter: Virtual device
    temp1:        +40.0°C  (crit = +65.0°C)
    
    coretemp-isa-0000
    Adapter: ISA adapter
    Physical id 0:  +41.0°C  (high = +80.0°C, crit = +99.0°C)
    Core 0:         +40.0°C  (high = +80.0°C, crit = +99.0°C)
    Core 1:         +39.0°C  (high = +80.0°C, crit = +99.0°C)
    Core 2:         +37.0°C  (high = +80.0°C, crit = +99.0°C)
    Core 3:         +39.0°C  (high = +80.0°C, crit = +99.0°C)
    And then I modified your script to be:

    Code:
    #!/bin/bash
    LOG=/usr/bin/logger
    DOWN=/sbin/shutdown
    ALERT_LEVEL=80
    SENSORSCMD=sensors
    
    CORE0TEMP=$($SENSORSCMD | grep -i "Core 0" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
    CORE1TEMP=$($SENSORSCMD | grep -i "Core 1" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
    CORE2TEMP=$($SENSORSCMD | grep -i "Core 2" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
    CORE3TEMP=$($SENSORSCMD | grep -i "Core 3" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
    
    if [[ $CORE0TEMP =~ "^[0-9]+$" ]]; then
       if [ $CORE0TEMP -ge $ALERT_LEVEL ]; then
           echo "The server **** is shutting down due to excessive Core 0 temp (it has reached a temperature of $CORE0TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
           $LOG "System going down as Core 0 has crossed its limit (temp=$CORE0TEMP°C, limit=$ALERT_LEVEL°C"
           sync;sync
           $DOWN -h 0
       fi
    fi
    
    if [[ $CORE1TEMP =~ "^[0-9]+$" ]]; then
       if [ $CORE1TEMP -ge $ALERT_LEVEL ]; then
          echo "The server **** is shutting down due to excessive Core 1 temp (it has reached a temperature of $CORE1TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
          $LOG "System going down as Core 1 has crossed its limit (temp=$CORE1TEMP°C, limit=$ALERT_LEVEL°C"
          sync;sync
          $DOWN -h 0
       fi
    fi
    
    if [[ $CORE2TEMP =~ "^[0-9]+$" ]]; then
       if [ $CORE2TEMP -ge $ALERT_LEVEL ]; then
           echo "The server **** is shutting down due to excessive Core 2 temp (it has reached a temperature of $CORE2TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
           $LOG "System going down as Core 2 has crossed its limit (temp=$CORE2TEMP°C, limit=$ALERT_LEVEL°C"
           sync;sync
           $DOWN -h 0
       fi
    fi
    
    if [[ $CORE3TEMP =~ "^[0-9]+$" ]]; then
       if [ $CORE3TEMP -ge $ALERT_LEVEL ]; then
           echo "The server **** is shutting down due to excessive Core 3 temp (it has reached a temperature of $CORE3TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
           $LOG "System going down as Core 3 has crossed its limit (temp=$CORE3TEMP°C, limit=$ALERT_LEVEL°C"
           sync;sync
           $DOWN -h 0
       fi
    fi
    Probably unnecessary to do all 4 cores since they're on the same chip, but I was a little fuzzy last night. If I get motivated and actually figure out how to write scripts I'll probably change to use just the Physical ID.

    When I set the ALERT_LEVEL to 1 and run it just does nothing at all. No shut down, no email. Just another command line. All the previous scripts have generated the appropriate emails and shutdowns.

    ETA: I just noticed that there's no "do" and "done" in the sensors_monitor.sh script. I think there should be, but I'm not really sure.
    Last edited by Bushflyr; March 26th, 2012 at 12:13 AM.

  7. #27
    Join Date
    Sep 2007
    Beans
    75

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    "do" and "done" are only needed if you have a for or while loop. In our case we are using simple if-then-else commands.

    As it turns out, you found another error in my original post!

    Sheesh.

    Took me a while to figure it out, but it turns out I have an error in my regular expression test.

    In all of the lines where I had put something like:

    Code:
    if [[ $CORE0TEMP =~ "^[0-9]+$" ]]; then
    I should have left the quotation marks off so it reads like this:

    Code:
    if [[ $CORE0TEMP =~ ^[0-9]+$ ]]; then
    Clearly I need to go back and check my stuff a little more thoroughly.



    So try the following code and let me know if it works:

    Code:
    #!/bin/bash
    LOG=/usr/bin/logger
    DOWN=/sbin/shutdown
    ALERT_LEVEL=80
    SENSORSCMD=sensors
    
    CORE0TEMP=$($SENSORSCMD | grep -i "Core 0" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
    CORE1TEMP=$($SENSORSCMD | grep -i "Core 1" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
    CORE2TEMP=$($SENSORSCMD | grep -i "Core 2" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
    CORE3TEMP=$($SENSORSCMD | grep -i "Core 3" | awk '{print $3}' | awk -F '°' '{print $1}' | awk -F '+' '{print $2}' | awk -F '.' '{print $1}')
    
    if [[ $CORE0TEMP =~ ^[0-9]+$ ]]; then
       if [ $CORE0TEMP -ge $ALERT_LEVEL ]; then
           echo "The server **** is shutting down due to excessive Core 0 temp (it has reached a temperature of $CORE0TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
           $LOG "System going down as Core 0 has crossed its limit (temp=$CORE0TEMP°C, limit=$ALERT_LEVEL°C"
           sync;sync
           $DOWN -h 0
       fi
    fi
    
    if [[ $CORE1TEMP =~ ^[0-9]+$ ]]; then
       if [ $CORE1TEMP -ge $ALERT_LEVEL ]; then
          echo "The server **** is shutting down due to excessive Core 1 temp (it has reached a temperature of $CORE1TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
          $LOG "System going down as Core 1 has crossed its limit (temp=$CORE1TEMP°C, limit=$ALERT_LEVEL°C"
          sync;sync
          $DOWN -h 0
       fi
    fi
    
    if [[ $CORE2TEMP =~ ^[0-9]+$ ]]; then
       if [ $CORE2TEMP -ge $ALERT_LEVEL ]; then
           echo "The server **** is shutting down due to excessive Core 2 temp (it has reached a temperature of $CORE2TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
           $LOG "System going down as Core 2 has crossed its limit (temp=$CORE2TEMP°C, limit=$ALERT_LEVEL°C"
           sync;sync
           $DOWN -h 0
       fi
    fi
    
    if [[ $CORE3TEMP =~ ^[0-9]+$ ]]; then
       if [ $CORE3TEMP -ge $ALERT_LEVEL ]; then
           echo "The server **** is shutting down due to excessive Core 3 temp (it has reached a temperature of $CORE3TEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive CPU temperature" ****@gmail.com
           $LOG "System going down as Core 3 has crossed its limit (temp=$CORE3TEMP°C, limit=$ALERT_LEVEL°C"
           sync;sync
           $DOWN -h 0
       fi
    fi

    I have updated the original post to fix this error.
    Last edited by bvz; March 26th, 2012 at 07:35 AM.

  8. #28
    Join Date
    Mar 2012
    Beans
    59

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Tried that and it works well, thanks.

    I also found, not really an error, but depending (I think) on the model of HDD the $4 in your hddtemp_monitor script needs to be changed to $3.

    I have Seagate drives, hddtemp outputs:

    Code:
    /dev/sdb: ST2000DL003-9VT166: 35°C
    and running your script returned:

    Code:
    /home/****/hddtemp_monitor.sh: line 11: [: -ge: unary operator expected
    /home/****/hddtemp_monitor.sh: line 11: [: -ge: unary operator expected
    /home/****/hddtemp_monitor.sh: line 11: [: -ge: unary operator expected
    /home/****/hddtemp_monitor.sh: line 11: [: -ge: unary operator expected
    Changing line 10 to read:

    Code:
    HDTEMP=$($HDT $disk | awk '{ print $3}' | awk -F '°' '{ print $1}')
    Fixed my issue.

    EDIT: Nope, guess it didn't. But it would have if I didn't have a mix of WD (/home) and Seagate (md0) drives. Trying to parse the different drive name formats is giving errors.

    Looking at THIS PAGE in the comments section gives what seems to be the solution, using the --numeric arg. Here's the script as I've got it running now and it hasn't kicked out any errors.

    Code:
    #!/bin/bash
    HDDS="/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde"
    HDT=/usr/sbin/hddtemp
    LOG=/usr/bin/logger
    DOWN=/sbin/shutdown
    ALERT_LEVEL=1
    args="--numeric"
    for disk in $HDDS
    do
    if [ -b $disk ]; then
        HDTEMP=$($HDT $disk $args)
        $LOG "HDTEMP for $disk is $HDTEMP"
            if [ $HDTEMP -ge $ALERT_LEVEL ]; then
                echo "The server **** is shutting down due to excessive hard drive temp. Drive: $disk has reached a temperature of $HDTEMP°C and has crossed its limit of $ALERT_LEVEL°C" | mail -s "ALERT! The server **** is shutting down due to excessive hard drive temperature" ****@gmail.com            
                $LOG "System going down as hard disk : $disk temperature $HDTEMP°C exceeded its limit"
                sync;sync
                $DOWN -h 0
            fi
    fi
    done


    The next thing is that gknw.net and gknw.de seem to be permanently down. Is there another source for the WOL package? I've started in using the Depicus page, but haven't gotten it working yet.

    And, in no particular order, the pm-suspend command completely broke my install. After much gnashing of teeth and reinstaling the OS and breaking it again, I figured out that COMPLETELY powering down the system, not just turning it off, but physically unplugging it from the wall would allow it to boot again. Working on that issue today.
    Last edited by Bushflyr; April 1st, 2012 at 09:28 PM.

  9. #29
    Join Date
    Mar 2012
    Beans
    59

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    And, I think there needs to be a section on setting the permissions after creating the various directories on the raid. I can see them on my Mac, but due to messed up permissions, I can't write to them.

  10. #30
    Join Date
    Apr 2012
    Beans
    9

    Re: Step by step guide to setting up Ubuntu 11.10 server for Newbies!

    Thanks for posting this!

Page 3 of 10 FirstFirst 12345 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •