]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - config/extrahd/extrahd.pl
Pakfire laedt die Listen jetzt besser und hat eine veraenderte Oberflaeche bekommen.
[people/teissler/ipfire-2.x.git] / config / extrahd / extrahd.pl
CommitLineData
aa2870e6
MT
1#!/usr/bin/perl
2#
3# IPFire Scripts
4#
5# This code is distributed under the terms of the GPL
6#
7# (c) The IPFire Team
8#
9
10use strict;
11# enable only the following on debugging purpose
12# use warnings;
13
14require '/var/ipfire/general-functions.pl';
15require "${General::swroot}/lang.pl";
16require "${General::swroot}/header.pl";
17
18my %extrahdsettings = ();
19my $ok = "true";
20my @devices = ();
21my @deviceline = ();
22my $deviceentry = "";
23my $devicefile = "/var/ipfire/extrahd/devices";
24my $fstab = "/var/ipfire/extrahd/fstab";
25
26### Values that have to be initialized
27$extrahdsettings{'PATH'} = '';
28$extrahdsettings{'FS'} = '';
29$extrahdsettings{'DEVICE'} = '';
30$extrahdsettings{'ACTION'} = '';
31
32open( FILE, "< $devicefile" ) or die "Unable to read $devicefile";
33@devices = <FILE>;
34close FILE;
35
36############################################################################################################################
37############################################################################################################################
38
39print "$ARGV[0] $ARGV[1]";
40
41if ( "$ARGV[0]" eq "mount" ) {
42 system("/bin/cp -f /etc/fstab $fstab");
43
44 foreach $deviceentry (sort @devices)
45 {
46 @deviceline = split( /\;/, $deviceentry );
47 if ( "$ARGV[1]" eq "$deviceline[2]" ) {
48 print "Insert /dev/$deviceline[0] ($deviceline[1]) --> $deviceline[2] into /etc/fstab!\n";
49 unless ( -d $deviceline[2] ) { system("/bin/mkdir -p $deviceline[2] && chmod 0777 $deviceline[2]"); }
50 open(FILE, ">>$fstab");
51 print FILE "/dev/$deviceline[0]\t$deviceline[2]\t$deviceline[1]\tdefaults\t0\t0\n";
52 close(FILE);
53 }
54 }
55
56 system("/bin/cp -f $fstab /etc/fstab");
57 if ( `/bin/mount -a` ) {
58 exit(0);
59 } else {
60 exit(1);
61 }
62
63} elsif ( "$ARGV[0]" eq "umount" ) {
64 system("/bin/umount $ARGV[1]");
65 if ( ! `/bin/mount | /bin/fgrep $ARGV[1]` ) {
66 system("/bin/cp -f /etc/fstab $fstab");
67 system("/bin/fgrep -v $ARGV[1] <$fstab >/etc/fstab");
68 print "Succesfully umounted $ARGV[1].\n";
69 exit(0);
70 } else {
71 print "Can't umount $ARGV[1].\n";
72 exit(1);
73 }
74
75} else {
76 print "Usage: $0 (mount|umount) mountpoint\n";
77}
78
79############################################################################################################################
80############################################################################################################################