| 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 message
|
|---|
| 18 | MOVE_TO_COL="echo -en \\033[${RES_COL}G" # command to move to the configured column number
|
|---|
| 19 |
|
|---|
| 20 | echo_success() { # function to print the SUCCESS status
|
|---|
| 21 | $MOVE_TO_COL; echo -n "[ OK ]"; echo
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | echo_failure() {
|
|---|
| 25 | $MOVE_TO_COL; echo -n "[FAILED]"; echo # function to print the FAILED status message
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | ### MAIN ###
|
|---|
| 31 |
|
|---|
| 32 | echo -n "Checking box type..."
|
|---|
| 33 | if [ "$model" = "" ]; then
|
|---|
| 34 | echo_failure
|
|---|
| 35 | echo
|
|---|
| 36 | echo "Sorry, $plugin is not available for the $model!"
|
|---|
| 37 | echo "Aborting installation..."
|
|---|
| 38 | exit 1
|
|---|
| 39 | else
|
|---|
| 40 | echo_success
|
|---|
| 41 | fi
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | echo -n "Checking installation directory..."
|
|---|
| 45 | if [ ! -d $plugin_target ]; then
|
|---|
| 46 | echo_failure
|
|---|
| 47 | echo
|
|---|
| 48 | echo "Sorry, $plugin_target not found!"
|
|---|
| 49 | echo "Aborting installation..."
|
|---|
| 50 | exit 1
|
|---|
| 51 | else
|
|---|
| 52 | echo_success
|
|---|
| 53 | fi
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | sync
|
|---|
| 57 | SPACE=`getfreespace $plugin_target`
|
|---|
| 58 | FREE=`expr $SPACE - 100`
|
|---|
| 59 | echo -n "Checking free space ($plugin_size in $FREE kB)..."
|
|---|
| 60 | if [ "$FREE" -lt "$plugin_size" ]; then
|
|---|
| 61 | echo_failure
|
|---|
| 62 | echo
|
|---|
| 63 | echo "Sorry, not enough free space in $plugin_target!"
|
|---|
| 64 | echo "Aborting installation..."
|
|---|
| 65 | exit 1
|
|---|
| 66 | else
|
|---|
| 67 | echo_success
|
|---|
| 68 | fi
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 | echo -n "Checking image type..."
|
|---|
| 72 | if [ `cat /etc/version | grep $buildgroup | wc -l` -eq 0 ]; then
|
|---|
| 73 | echo_failure
|
|---|
| 74 | echo
|
|---|
| 75 | echo "Sorry, $plugin is not available for this image type!"
|
|---|
| 76 | echo "Aborting installation..."
|
|---|
| 77 | exit 1
|
|---|
| 78 | else
|
|---|
| 79 | echo_success
|
|---|
| 80 | fi
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 | rm -rf $plugin_dir
|
|---|
| 84 |
|
|---|
| 85 | echo -n "Installing $plugin..."
|
|---|
| 86 | echo_success
|
|---|
| 87 |
|
|---|
| 88 | exit 0
|
|---|