source: ipk/source.sh4/titanswapskins_tobayer01/CONTROL/preinst@ 23248

Last change on this file since 23248 was 23248, checked in by tobayer, 13 years ago

[titan] tobayer01 swapskin: change echo with escape to printf

File size: 1.6 KB
Line 
1#!/bin/sh
2
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
11model=`cat /etc/model`
12buildgroup=`cat /etc/.buildgroup`
13
14
15### FUNCTIONS ###
16
17RES_COL=60 # column number to place the status
18
19echo_success() { # function to print the OK status
20 printf "%-${RES_COL}s%s\n" "$1" "[ OK ]"
21}
22
23echo_failure() { # function to print the FAILED status
24 printf "%-${RES_COL}s%s\n" "$1" "[FAILED]"
25}
26
27
28
29### MAIN ###
30
31msg="Checking box type..."
32if [ "$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
38else
39 echo_success "$msg"
40fi
41
42
43msg="Checking installation directory..."
44if [ ! -d $plugin_target ]; then
45 echo_failure "$msg"
46 echo
47 echo "Sorry, $plugin_target not found!"
48 echo "Aborting installation..."
49 exit 1
50else
51 echo_success "$msg"
52fi
53
54
55sync
56SPACE=`getfreespace $plugin_target`
57FREE=`expr $SPACE - 100`
58msg="Checking free space ($plugin_size in $FREE kB)..."
59if [ "$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
65else
66 echo_success "$msg"
67fi
68
69
70msg="Checking image type..."
71if [ `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
77else
78 echo_success "$msg"
79fi
80
81
82rm -rf $plugin_dir
83
84msg="Installing $plugin..."
85echo_success "$msg"
86
87exit 0
Note: See TracBrowser for help on using the repository browser.