| 1 | #!/bin/sh
|
|---|
| 2 |
|
|---|
| 3 | plugin_size=2300
|
|---|
| 4 | plugin_short="tobayer01"
|
|---|
| 5 | plugin_type="swapskin"
|
|---|
| 6 | plugin_target="/var/swap/titanskins"
|
|---|
| 7 |
|
|---|
| 8 | plugin_dir="$plugin_target/$plugin_short"
|
|---|
| 9 | plugin="$plugin_short $plugin_type"
|
|---|
| 10 |
|
|---|
| 11 | model=`cat /etc/model`
|
|---|
| 12 | buildgroup=`cat /etc/.buildgroup`
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | ### FUNCTIONS ###
|
|---|
| 16 |
|
|---|
| 17 | RES_COL=60 # column number to place the status
|
|---|
| 18 |
|
|---|
| 19 | echo_success() { # function to print the OK status
|
|---|
| 20 | printf "%-${RES_COL}s%s\n" "$1" "[ OK ]"
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | echo_failure() { # function to print the FAILED status
|
|---|
| 24 | printf "%-${RES_COL}s%s\n" "$1" "[FAILED]"
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 | ### MAIN ###
|
|---|
| 30 |
|
|---|
| 31 | msg="Checking box type..."
|
|---|
| 32 | if [ "$model" = "" ]; then
|
|---|
| 33 | echo_failure "$msg"
|
|---|
| 34 | echo
|
|---|
| 35 | echo "Sorry, $plugin is not available for the $model!"
|
|---|
| 36 | echo "Aborting installation..."
|
|---|
| 37 | exit 1
|
|---|
| 38 | else
|
|---|
| 39 | echo_success "$msg"
|
|---|
| 40 | fi
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | msg="Checking installation directory..."
|
|---|
| 44 | if [ ! -d $plugin_target ]; then
|
|---|
| 45 | echo_failure "$msg"
|
|---|
| 46 | echo
|
|---|
| 47 | echo "Sorry, $plugin_target not found!"
|
|---|
| 48 | echo "Aborting installation..."
|
|---|
| 49 | exit 1
|
|---|
| 50 | else
|
|---|
| 51 | echo_success "$msg"
|
|---|
| 52 | fi
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 | sync
|
|---|
| 56 | SPACE=`getfreespace $plugin_target`
|
|---|
| 57 | FREE=`expr $SPACE - 100`
|
|---|
| 58 | msg="Checking free space ($plugin_size in $FREE kB)..."
|
|---|
| 59 | if [ "$FREE" -lt "$plugin_size" ]; then
|
|---|
| 60 | echo_failure "$msg"
|
|---|
| 61 | echo
|
|---|
| 62 | echo "Sorry, not enough free space in $plugin_target!"
|
|---|
| 63 | echo "Aborting installation..."
|
|---|
| 64 | exit 1
|
|---|
| 65 | else
|
|---|
| 66 | echo_success "$msg"
|
|---|
| 67 | fi
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 | msg="Checking image type..."
|
|---|
| 71 | if [ `cat /etc/version | grep $buildgroup | wc -l` -eq 0 ]; then
|
|---|
| 72 | echo_failure "$msg"
|
|---|
| 73 | echo
|
|---|
| 74 | echo "Sorry, $plugin is not available for this image type!"
|
|---|
| 75 | echo "Aborting installation..."
|
|---|
| 76 | exit 1
|
|---|
| 77 | else
|
|---|
| 78 | echo_success "$msg"
|
|---|
| 79 | fi
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | rm -rf $plugin_dir
|
|---|
| 83 |
|
|---|
| 84 | msg="Installing $plugin..."
|
|---|
| 85 | echo_success "$msg"
|
|---|
| 86 |
|
|---|
| 87 | exit 0
|
|---|