1 | #!/bin/bash␊ |
2 | ␊ |
3 | echo "==============================================="␊ |
4 | echo "InstallLog: Create/Append installation log"␊ |
5 | echo "**********************************************"␊ |
6 | ␊ |
7 | # Creates text file named 'Chameleon_Installer_Log.txt'␊ |
8 | # at the root of the target volume. This is to help show the␊ |
9 | # user why the installation process failed (even though the␊ |
10 | # package installer ends reading 'Installation Successful'. ␊ |
11 | ␊ |
12 | # Receives two parameters␊ |
13 | # $1 = selected volume for location of the install log␊ |
14 | # $2 = text to write to the installer log␊ |
15 | ␊ |
16 | if [ "$#" -eq 2 ]; then␊ |
17 | ␉logLocation="$1"␊ |
18 | ␉verboseText="$2"␊ |
19 | ␉echo "DEBUG: passed argument = $logLocation"␊ |
20 | ␉echo "DEBUG: passed argument = $verboseText"␊ |
21 | else␊ |
22 | ␉echo "Error - wrong number of values passed"␊ |
23 | ␉exit 9␊ |
24 | fi␊ |
25 | ␊ |
26 | logName="Chameleon_Installer_Log.txt"␊ |
27 | logFile="${logLocation}"/$logName␊ |
28 | ␊ |
29 | # On first run, create a file named .ChameleonLogFlag at␊ |
30 | # the root of the target volume. Then check for this file␊ |
31 | # on subsequent runs to know the initialisation sequence␊ |
32 | # has been done.␊ |
33 | ␊ |
34 | if [ ! -f "${logLocation}"/.ChameleonLogFlag ]; then␊ |
35 | ␉# This is the first run, so setup ␊ |
36 | ␉# Chameleon_Installer_Log.txt file␊ |
37 | ␉# by writing header.␊ |
38 | ␊ |
39 | ␉# Also include the first message that this script␊ |
40 | ␉# would be called with which will be version/revision␊ |
41 | ␉# of Chameleon package.␊ |
42 | ␊ |
43 | ␉echo "Chameleon installer log - $( date )␊ |
44 | ${verboseText}␊ |
45 | ======================================================␊ |
46 | " >"${logFile}"␊ |
47 | ␉diskutil list >>"${logFile}"␊ |
48 | ␉echo "␊ |
49 | ======================================================␊ |
50 | " >>"${logFile}"␊ |
51 | ␊ |
52 | ␉# Create /.ChameleonLogFlag file.␊ |
53 | ␉echo "Log" >"${logLocation}"/.ChameleonLogFlag␊ |
54 | else␊ |
55 | ␉# Append messages to the log as passed by other scripts.␊ |
56 | ␉if [ "${verboseText}" = "Line Break" ]; then␊ |
57 | ␉␉echo "␊ |
58 | ======================================================␊ |
59 | " >>"${logFile}"␊ |
60 | ␉fi␊ |
61 | ␊ |
62 | ␉if [[ "${verboseText}" == *fdisk* ]]; then␊ |
63 | ␉␉targetDiskRaw="${verboseText#fdisk *}"␊ |
64 | ␉␉fdisk $targetDiskRaw >>"${logFile}"␊ |
65 | ␉␉echo " " >>"${logFile}"␊ |
66 | ␉fi␊ |
67 | ␊ |
68 | ␉if [ "${verboseText}" != "Line Break" ] && [[ "${verboseText}" != *fdisk* ]]; then␊ |
69 | ␉␉echo "${verboseText}" >> "${logFile}"␊ |
70 | ␉fi␊ |
71 | fi␊ |
72 | ␊ |
73 | exit 0 |