Utilities

by willemkokke
0 deployments · 0 still active · last rev. 1 year ago

This is a library of utility functions

Do not deploy directly, but include it with:

source <ssinclude StackScriptID=14154>

@willemkokke

Compatible with: Ubuntu 14.04 LTS
						#!/bin/bash

function log {
    # log(string)
    echo `date +"%Y-%m-%d %H:%M:%S"` $1 >> ~/StackScript.log
}

function lowercase {
    # lowercase(string)
    echo $1 | tr '[:upper:]' '[:lower:]'
}

function restart_services {
    # restart all services that have a file in /tmp/restart

    for service in $(ls /tmp/restart-* | cut -d- -f2-10); do
        log "Restarting service $service"
        restart $service
        rm -f /tmp/restart-$service
    done
}

function system_update {
    log "Updating server packages using aptitude"
    apt-get update
    apt-get -y install aptitude
    aptitude -y full-upgrade
    log "Updating server packages done"
}