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

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

[titan] tobayer01 swapskin: optimize control files

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 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..."
33if [ "$model" = "" ]; then
34 echo_failure
35 echo
36 echo "Sorry, $plugin is not available for the $model!"
37 echo "Aborting installation..."
38 exit 1
39else
40 echo_success
41fi
42
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..."
50 exit 1
51else
52 echo_success
53fi
54
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
66else
67 echo_success
68fi
69
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..."
77 exit 1
78else
79 echo_success
80fi
81
82
83rm -rf $plugin_dir
84
85echo -n "Installing $plugin..."
86echo_success
87
88exit 0
Note: See TracBrowser for help on using the repository browser.