File: initscript

package info (click to toggle)
translucency 0.6.0-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 240 kB
  • ctags: 221
  • sloc: ansic: 2,133; makefile: 260; perl: 172; sh: 102
file content (144 lines) | stat: -rwxr-xr-x 2,829 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
#
# init-script for translucency
#
# this script works though a config file and tries to set up translucency
# for each line in this file. comments and whitespaces are ignored.
# The first thing expected in the config is the source separated by some
# blanks/tabs from the target. the line
#
# /   /tmp # some comment here
#
# will enable translucency from / to /tmp.
#
# The config-files should be placed in the directory /etc/translucency. The file
# holding the forwards as described above should be named mappings. Two additional
# files, run-up and run-down, may exist holding commands to be executed right
# before translucency is set up (repectively right after translucency has been
# turned off). this may be used to mount a ramdisk used by translucency.
#
# NOTE: this script writes all map-rules from the config-file to /proc,
# even though the maximal number of forwardings is limited in base.h. By default
# only the first eight rules are applied.
#
# fabian thorns (fabian@thorns.it), 30. 8. 2003
#
# this script is free software in the sense of the terms of the GNU GPL version 2,
# or (at your option) any later version.


# Full path to the config-files
CONF_DIR=/etc/translucency


# This makes the appeareance a bit smater but should be commented
# out for debugging

printk=`cat /proc/sys/kernel/printk`
echo "0 0 0 0" > /proc/sys/kernel/printk


# Here we go ...

case "$1" in

start)
   echo -n "Setting up Translucency: "

   # Let's see if we are ready

   if [ ! -d /proc/sys/translucency ]
   then
      if ! insmod translucency
      then
         echo "failed."
         exit 1
      fi
   fi

   # So far everything looks good, let's run pre-config scripts.

   if [ -f $CONF_DIR/run-up ]
   then
      . $CONF_DIR/run-up
   fi

   # OK, Let's work though the config.

   if [ -f $CONF_DIR/mappings ]
   then
      i=0

      while read from to odd
      do

         case "$from" in
         ""|\#)
            continue
         ;;
         esac

         echo -n "$from -> $to, "

         echo -n "$from -> $to" > /proc/sys/translucency/$i

         i=$[$i+1]
      done < $CONF_DIR/mappings

      echo "done."
   else
      echo "$CONF/mappings: File not found."
      exit 1
   fi
;;


stop)
   echo -n "Disabling Translucency: "

   for i in /proc/sys/translucency/[0-9]*
   do
      echo > $i
   done

   if ! rmmod translucency
   then
      echo "failed."
      exit 1
   fi

   if [ -f $CONF_DIR/run-down ]
   then
      . $CONF_DIR/run-down
   fi

   echo "done."
;;

status)
   if /sbin/lsmod|grep -q translucency ; then
     echo running
   else
     echo unused
   fi
;;

restart)
   $0 stop
   $0 start
;;

*)
   echo "Usage $0 {start|stop|restart|status}"
;;

esac


# Restore old status of printk
echo $printk > /proc/sys/kernel/printk


# That's it for today :-)

exit 0