Documentation/SupportedImages/BuildingBaselineImage: prepare.sh

File prepare.sh, 1.2 KB (added by ssugrim, 10 years ago)

Updated prepare file to deal with hostnames

Line 
1#!/bin/bash
2# Run this before you save the image
3# Version 1.0 Edited by James - 7/28/2014
4
5# Fix apt stuff
6apt-get clean
7apt-get update
8
9# Root user stuff to clean
10CLEAN_ROOT="/root/.ssh /root/.viminfo /root/.lesshst /root/.bash_history"
11
12# Tmp stuff to clean
13CLEAN_TMP="/tmp/* /var/tmp/"
14
15# We do not want documentation on our baselines
16CLEAN_DOC="/usr/doc/* /usr/share/doc/*"
17
18# Udev data to clean. Udev likes keeps interface names persistent accross bootups. We
19# do not want that behaviour because we move the image to different hardware
20# so we remove the saved rules and the generator rules
21CLEAN_UDEV="/etc/udev/rules.d/70-persistent-net.rules"
22
23#Dump old logs
24CLEAN_LOGS="/var/log/*"
25
26# Detel all the data we want gone
27CLEAN="$CLEAN_TMP $CLEAN_DOC $CLEAN_UDEV $CLEAN_ROOT"
28rm -rf $CLEAN
29
30#log clean up fix
31find /var/log -type f -regex ".*\.gz$" -delete
32find /var/log -type f -regex ".*\.[0-9]$" -delete
33find /var/log -type f -exec cp /dev/null {} \;
34
35# Old logs
36rm /etc/hostname
37history -c
38
39#Prevent Udev from makeing persistent rules:
40ln -s /dev/null /etc/udev/rules.d/70-persistent-net.rules
41
42#make sure there are no rogue Name resloutions in /etc/hosts
43ruby -i.bak -ne 'print if not /node\d-\d.*orbit/' /etc/hosts
44
45poweroff