Ignore:
Timestamp:
Sep 4, 2013, 12:34:44 AM (13 years ago)
Author:
tobayer
Message:

[titan] tobayer01 swapskin: optimize control files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ipk/source.sh4/titanswapskins_tobayer01/CONTROL/preinst

    r23202 r23247  
    11#!/bin/sh
    22
    3 plugin="tobayer01 swapskin"
    4 plugindir="/var/swap/titanskins/tobayer01"
    5 pluginsize=2300
     3plugin_size=2300
     4plugin_short="tobayer01"
     5plugin_type="swapskin"
     6plugin_target="/var/swap/titanskins"
     7
     8plugin_dir="$plugin_target/$plugin_short"
     9plugin="$plugin_short $plugin_type"
     10
    611model=`cat /etc/model`
    7 link=`readlink /var/swap`
    812buildgroup=`cat /etc/.buildgroup`
    913
    10 sync
    1114
    12 echo "Checking your box type..."
     15### FUNCTIONS ###
     16
     17RES_COL=60                                                                      # column number to place the status message
     18MOVE_TO_COL="echo -en \\033[${RES_COL}G"        # command to move to the configured column number
     19
     20echo_success() {                                                        # function to print the SUCCESS status
     21        $MOVE_TO_COL; echo -n "[  OK  ]"; echo
     22}
     23
     24echo_failure() {
     25        $MOVE_TO_COL; echo -n "[FAILED]"; echo  # function to print the FAILED status message
     26}
     27
     28
     29
     30### MAIN ###
     31
     32echo -n "Checking box type..."
    1333if [ "$model" = "" ]; then
    14         echo ""
    15         echo "Sorry! This plugin is not available for your $model, because it will not work correctly!"
     34        echo_failure
     35        echo
     36        echo "Sorry, $plugin is not available for the $model!"
    1637        echo "Aborting installation..."
    1738        exit 1
    1839else
    19         echo "Box type $model is OK."
     40        echo_success
    2041fi
    2142
    22 echo ""
    23 echo "Checking swapstick..."
    24 if [ ! -d /var/swap/titanskins/ ]; then
    25         echo "----------------------"
    26         echo "Swapstick not found..."
    27         echo "----------------------"
     43
     44echo -n "Checking installation directory..."
     45if [ ! -d $plugin_target ]; then
     46        echo_failure
     47        echo
     48        echo "Sorry, $plugin_target not found!"
     49        echo "Aborting installation..."
    2850        exit 1
    2951else
    30         echo "Swapstick is OK."
     52        echo_success
    3153fi
    3254
    33 if [ `df | grep /dev/mtdblock | grep mnt | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1 | wc -l` -eq 1 ] && [ $link = "/mnt/swapextensions" ]; then
    34         SPACE=`df | grep /dev/mtdblock | grep mnt | sed 's/ \+/ /g' | cut -d ' ' -f4 | head -n1`
    35         FREE=`expr $SPACE - 100`
    36         echo ""
    37         echo "Checking free space..."
    38         echo "Package size $pluginsize kb"
    39         echo "Free space $FREE kb"
    40         if [ "$FREE" -lt "$pluginsize" ]; then
    41                 echo "Sorry, not enough free space on your device!"
    42                 exit 1
    43         else
    44                 echo "OK"
    45         fi
     55
     56sync
     57SPACE=`getfreespace $plugin_target`
     58FREE=`expr $SPACE - 100`
     59echo -n "Checking free space ($plugin_size in $FREE kB)..."
     60if [ "$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
    4666else
    47         sync
     67        echo_success
    4868fi
    4969
    50 echo ""
    51 echo "Checking OS..."
    52 if [ `cat /etc/motd | grep $buildgroup | grep M | grep rev | wc -l` -eq 0 ]; then               
    53         echo "---------------------------"
    54         echo "Don't use this TPK package!"
    55         echo "---"
    56         echo "Only for $buildgroup image!"
    57         echo "---------------------------"
     70
     71echo -n "Checking image type..."
     72if [ `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..."
    5877        exit 1
    5978else
    60         echo "OS is OK."
     79        echo_success
    6180fi
    6281
    63 rm -rf $plugindir
    64 echo ""
    65 echo "Installing $plugin..."
     82
     83rm -rf $plugin_dir
     84
     85echo -n "Installing $plugin..."
     86echo_success
    6687
    6788exit 0
Note: See TracChangeset for help on using the changeset viewer.