north5_ubuntu_basic

by north5
0 deployments · 0 still active · last rev. 3 years ago

Basic lib of bash functions

Compatible with: No distros currently supported
						#!/bin/bash

# <udf name="ubuntu_mirror" label="ubuntu mirror url" default="http://archive.ubuntu.com/ubuntu/">
# <udf name="hostname" label="hostname">

# Set software sources
function set_sources_list() {
  echo "Adjusting sources.list (destructively)" >> $logfile
  CODENAME=$(lsb_release -sc)

  cat >/etc/apt/sources.list <<EOF
deb $UBUNTU_MIRROR $CODENAME main restricted universe multiverse
deb-src $UBUNTU_MIRROR $CODENAME main restricted universe multiverse

deb $UBUNTU_MIRROR $CODENAME-updates main restricted universe multiverse
deb-src $UBUNTU_MIRROR $CODENAME-updates main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu $CODENAME-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu $CODENAME-security main restricted universe multiverse
EOF
}

# Set hostname
function set_hostname() {
  echo "Setting Hostname to ${HOSTNAME}" >> $logfile
  echo ${HOSTNAME} > /etc/hostname
  hostname -F /etc/hostname
  short=$(hostname -s)
  echo "127.0.1.1 ${short} ${short}" >> /etc/hosts
}

# Update software repositories and perform upgrade
function system_upgrade() {
  echo "Update system packages" >> $logfile
  apt-get -y update
  apt-get -y upgrade
}

# Clean system packages
function system_clean() {
  apt-get -y autoremove
  apt-get -y clean  
}

# Install north5 common packages
function north5_packages() {
  apt-get -y install build-essential
  apt-get -y install curl htop

  apt-get -y remove apparmor

  RELEASE=$(lsb_release -sr)

  # Ubuntu 12.04 already has these scripts integrated
  if [[ ${RELEASE} == "10.04" ]]; then
    apt-get -y install python-software-properties
  fi
}

# Default log file
logfile=${logfile:-"/root/stackscript.log"}