File: unload_module.sh

package info (click to toggle)
plex86 0.0.20011018-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,868 kB
  • ctags: 8,721
  • sloc: ansic: 46,915; cpp: 17,817; xml: 1,283; makefile: 1,130; sh: 451; asm: 360; csh: 18
file content (34 lines) | stat: -rwxr-xr-x 845 bytes parent folder | download | duplicates (7)
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
#! /bin/bash
#
# A simple script to unload the kernel module and remove the old device nodes
# for it.
#
# Note:
# this must be run as root
#

# Check that root is executing us
if [ "$EUID" != "0" ]; then
    echo "Sorry, you need to be root for this script to work."
    echo "use 'su -c $0' and enter the root password when prompted"
    exit -1
fi

# Check if the module is already loaded
if [ "x`grep plex86 /proc/devices`" != "x" ]; then
    /sbin/rmmod plex86

    # Check that it really went (OK - I'm paranoid)
    if [ "x`grep plex86 /proc/devices`" != "x" ]; then
	echo "The kernel module failed to unload!"
	exit -1
    fi
fi

# Remove any stale device nodes
# (extend for any minor devices created in the future)
rm -f /dev/plex86

# Job done - Give a little positive feedback
echo "The kernel module is no longer installed."
exit 0