📄 linux-lib.pl
字号:
else { printf "<option value=3 %s> User and Group\n", $usrquota && $grpquota ? "selected" : ""; } print "</select></td> </tr>\n"; print "<tr> <td><b>Reserve space for user</b></td>\n"; printf "<td><input name=ext2_resuid size=8 value=\"%s\">\n", defined($options{"resuid"}) ? getpwuid($options{"resuid"}) : ""; print &user_chooser_button("ext2_resuid", 0),"</td>\n"; print "<td><b>Reserve space for group</b></td>\n"; printf "<td><input name=ext2_resgid size=8 value=\"%s\">\n", defined($options{"resgid"}) ? getgrgid($options{"resgid"}) : ""; print &group_chooser_button("ext2_resgid", 0),"</td> </tr>\n"; }if ($_[0] eq "nfs") { # Linux nfs has some more options... print "<tr> <td><b>Retry mounts in background?</b></td>\n"; printf "<td nowrap><input type=radio name=nfs_bg value=1 %s> Yes\n", defined($options{"bg"}) ? "checked" : ""; printf "<input type=radio name=nfs_bg value=0 %s> No</td>\n", defined($options{"bg"}) ? "" : "checked"; print "<td><b>Return error on timeouts?</b></td>\n"; printf "<td nowrap><input type=radio name=nfs_soft value=1 %s> Yes\n", defined($options{"soft"}) ? "checked" : ""; printf "<input type=radio name=nfs_soft value=0 %s> No</td> </tr>\n", defined($options{"soft"}) ? "" : "checked"; print "<tr> <td><b>Timeout</b></td>\n"; printf "<td nowrap><input type=radio name=nfs_timeo_def value=1 %s> Default\n", defined($options{"timeo"}) ? "" : "checked"; printf "<input type=radio name=nfs_timeo_def value=0 %s>\n", defined($options{"timeo"}) ? "checked" : ""; printf "<input size=5 name=nfs_timeo value=$options{timeo}></td>\n"; print "<td><b>Number of Retransmissions</b></td>\n"; printf "<td nowrap><input type=radio name=nfs_retrans_def value=1 %s> Default\n", defined($options{"retrans"}) ? "" : "checked"; printf "<input type=radio name=nfs_retrans_def value=0 %s>\n", defined($options{"retrans"}) ? "checked" : ""; print "<input size=5 name=nfs_retrans value=$options{retrans}></td> </tr>\n"; print "<tr> <td><b>NFS version</b></td>\n"; printf "<td nowrap><input type=radio name=nfs_vers_def value=1 %s> Highest\n", defined($options{"nfsvers"}) ? "" : "checked"; printf "<input type=radio name=nfs_vers_def value=0 %s>\n", defined($options{"nfsvers"}) ? "checked" : ""; print "<input size=1 name=nfsvers value=$options{nfsvers}></td>\n"; print "<td><b>NFS Port</b></td>\n"; printf "<td nowrap><input type=radio name=nfs_port_def value=1 %s> Default\n", defined($options{"port"}) ? "" : "checked"; printf "<input type=radio name=nfs_port_def value=0 %s>\n", defined($options{"port"}) ? "checked" : ""; print "<input size=5 name=nfs_port value=$options{port}></td> </tr>\n"; print "<tr> <td><b>Allow user interrupt?</b></td>\n"; printf "<td nowrap><input type=radio name=nfs_intr value=1 %s> Yes\n", defined($options{"intr"}) ? "checked" : ""; printf "<input type=radio name=nfs_intr value=0 %s> No</td>\n", defined($options{"intr"}) ? "" : "checked"; print "<td><b>RPC Protocol</b></td>\n"; printf "<td nowrap><input type=radio name=nfs_tcp value=1 %s> TCP\n", defined($options{"tcp"}) ? "checked" : ""; printf "<input type=radio name=nfs_tcp value=0 %s> UDP</td> </tr>\n", defined($options{"tcp"}) ? "" : "checked"; }if ($_[0] eq "fat" || $_[0] eq "vfat" || $_[0] eq "msdos" || $_[0] eq "umsdos"){ # All dos-based filesystems share some options print "<tr> <td><b>User files are owned by</b></td>\n"; printf "<td><input name=fat_uid size=8 value=\"%s\">\n", defined($options{'uid'}) ? getpwuid($options{'uid'}) : ""; print &user_chooser_button("fat_uid", 0),"</td>\n"; print "<td><b>Group files are owned by</b></td>\n"; printf "<td><input name=fat_gid size=8 value=\"%s\">\n", defined($options{'gid'}) ? getgrgid($options{'gid'}) : ""; print &group_chooser_button("fat_gid", 0),"</td> </tr>\n"; print "<tr> <td><b>File naming rules</b></td>\n"; print "<td><select name=fat_check>\n"; printf "<option value=\"\" %s> Default\n", defined($options{"check"}) ? "" : "selected"; printf "<option value=r %s> Relaxed\n", $options{"check"} =~ /^r/ ? "selected" : ""; printf "<option value=n %s> Normal\n", $options{"check"} =~ /^n/ ? "selected" : ""; printf "<option value=s %s> Strict\n", $options{"check"} =~ /^s/ ? "selected" : ""; print "</select></td>\n"; print "<td><b>DOS-Unix newline conversion</b></td>\n"; print "<td><select name=fat_conv>\n"; printf "<option value=\"\" %s> None\n", $options{"conv"} =~ /^b/ || !defined($options{"conv"}) ? "selected" : ""; printf "<option value=t %s> All files\n", $options{"conv"} =~ /^t/ ? "selected" : ""; printf "<option value=a %s> Text files only\n", $options{"conv"} =~ /^a/ ? "selected" : ""; print "</select></td> </tr>\n"; print "<tr> <td><b>File permissions mask</b></td>\n"; printf "<td><input type=radio name=fat_umask_def value=1 %s> Default\n", defined($options{"umask"}) ? "" : "checked"; printf "<input type=radio name=fat_umask_def value=0 %s>\n", defined($options{"umask"}) ? "checked" : ""; print "<input size=5 name=fat_umask value=\"$options{umask}\"></td>\n"; print "<td><b>Report errors on <tt>chown</tt> attempts?</b></td>\n"; printf "<td nowrap><input type=radio name=fat_quiet value=0 %s> Yes\n", defined($options{"quiet"}) ? "" : "checked"; printf "<input type=radio name=fat_quiet value=1 %s> No</td> </tr>\n", defined($options{"quiet"}) ? "checked" : ""; }if ($_[0] eq "vfat") { # vfat has some extra options beyond fat print "<tr> <td><b>Translate Unicode characters?</b></td>\n"; printf "<td><input type=radio name=fat_uni_xlate value=1 %s> Yes\n", defined($options{"uni_xlate"}) ? "checked" : ""; printf "<input type=radio name=fat_uni_xlate value=0 %s> No</td>\n", defined($options{"uni_xlate"}) ? "" : "checked"; print "<td><b>Allow names that differ only in case?</b></td>\n"; printf "<td nowrap><input type=radio name=fat_posix value=1 %s> Yes\n", defined($options{"posix"}) ? "checked" : ""; printf "<input type=radio name=fat_posix value=0 %s> No</td> </tr>\n", defined($options{"posix"}) ? "" : "checked"; }if ($_[0] eq "hpfs") { # OS/2 filesystems has some more options.. print "<tr> <td><b>User files are owned by</b></td>\n"; printf "<td><input name=hpfs_uid size=8 value=\"%s\">\n", defined($options{"uid"}) ? getpwuid($options{"uid"}) : ""; print &user_chooser_button("hpfs_uid", 0),"</td>\n"; print "<td><b>Group files are owned by</b></td>\n"; printf "<td><input name=hpfs_gid size=8 value=\"%s\">\n", defined($options{"gid"}) ? getgrgid($options{"gid"}) : ""; print &group_chooser_button("hpfs_gid", 0),"</td> </tr>\n"; print "<tr> <td><b>File permissions mask</b></td>\n"; printf"<td><input type=radio name=hpfs_umask_def value=1 %s> Default\n", defined($options{"umask"}) ? "" : "checked"; printf "<input type=radio name=hpfs_umask_def value=0 %s>\n", defined($options{"umask"}) ? "checked" : ""; print "<input size=5 name=hpfs_umask value=\"$options{umask}\"></td>\n"; print "<td><b>OS/2-Unix newline conversion</b></td>\n"; print "<td><select name=hpfs_conv>\n"; printf "<option value=b %s> None\n", $options{"conv"} =~ /^b/ || !defined($options{"conv"}) ? "selected" : ""; printf "<option value=t %s> All files\n", $options{"conv"} =~ /^t/ ? "selected" : ""; printf "<option value=a %s> Text files only\n", $options{"conv"} =~ /^a/ ? "selected" : ""; print "</select></td> </tr>\n"; }if ($_[0] eq "iso9660") { # CD-ROM filesystems have some more options.. print "<tr> <td><b>User files are owned by</b></td>\n"; printf "<td><input name=iso9660_uid size=8 value=\"%s\">\n", defined($options{"uid"}) ? getpwuid($options{"uid"}) : ""; print &user_chooser_button("iso9660_uid", 0),"</td>\n"; print "<td><b>Group files are owned by</b></td>\n"; printf "<td><input name=iso9660_gid size=8 value=\"%s\">\n", defined($options{"gid"}) ? getgrgid($options{"gid"}) : ""; print &group_chooser_button("iso9660_gid", 0),"</td>\n"; print "<tr> <td><b>Ignore Unix Attributes?</b></td>\n"; printf "<td><input type=radio name=iso9660_norock value=1 %s> Yes\n", defined($options{"norock"}) ? "checked" : ""; printf "<input type=radio name=iso9660_norock value=0 %s> No</td>\n", defined($options{"norock"}) ? "" : "checked"; print "</tr>\n"; print "<td><b>File permissions for non-Unix CDs</b></td>\n"; printf"<td><input size=10 name=iso9660_mode value=\"%s\"></td> </tr>\n", defined($options{"mode"}) ? $options{"mode"} : "444"; }if ($_[0] eq "auto") { # Don't know how to set options for auto filesystems yet.. print "<tr> <td><i>No Options Available</i></td> </tr>\n"; }if ($_[0] eq "autofs") { print "<tr> <td><b>Idle time before unmount</b></td> <td>\n"; printf"<input type=radio name=autofs_timeout_def value=1 %s> Default\n", defined($options{'timeout'}) ? "" : "checked"; printf "<input type=radio name=autofs_timeout_def value=0 %s>\n", defined($options{'timeout'}) ? "checked" : ""; printf "<input name=autofs_timeout size=5 value=\"%s\"> Secs</td>\n", $options{'timeout'}; print "<td><b>Write PID to file</b>?</td>\n"; printf"<td><input type=radio name=autofs_pid-file_def value=1 %s> No\n", defined($options{'pid-file'}) ? "" : "checked"; printf "<input type=radio name=autofs_pid-file_def value=0 %s> Yes\n", defined($options{'pid-file'}) ? "checked" : ""; printf "<input name=autofs_pid-file size=20 value=\"%s\">\n", $options{'pid-file'}; print &file_chooser_button("autofs_pid-file", 1); print "</td> </tr>\n"; }if ($_[0] eq "swap") { # Swap has no options.. print "<tr> <td><i>No Options Available</i></td> </tr>\n"; }if ($_[0] eq "smbfs") { # SMB filesystems have a few options.. if (keys(%options) == 0 && !$_[1]) { print "<tr> <td colspan=4><i>Warning! Filesystem was not ", "mounted from Webmin, so existing options are not available", "</i></td> </tr>\n"; } print "<tr> <td><b>Login Name</b></td>\n"; print "<td><input name=smbfs_user size=15 ", "value=\"$options{'user'}\"></td>\n"; print "<td><b>Login Password</b></td>\n"; print "<td><input type=password name=smbfs_passwd size=15 ", "value=\"$options{'passwd'}\"></td> </tr>\n"; if ($smbfs_support != 2) { print "<tr> <td><b>User files are owned by</b></td>\n"; printf "<td><input name=smbfs_uid size=8 value=\"%s\">\n", defined($options{"uid"}) ? getpwuid($options{"uid"}) : ""; print &user_chooser_button("smbfs_uid", 0),"</td>\n"; print "<td><b>Group files are owned by</b></td>\n"; printf "<td><input name=smbfs_gid size=8 value=\"%s\">\n", defined($options{"gid"}) ? getgrgid($options{"gid"}) : ""; print &group_chooser_button("smbfs_gid", 0),"</td>\n"; } if ($smbfs_support == 1) { print "<tr> <td><b>Server Name</b></td>\n"; printf "<td><input type=radio name=smbfs_sname_def value=1 %s> Automatic\n", defined($options{"servername"}) ? "" : "checked"; printf "<input type=radio name=smbfs_sname_def value=0 %s>\n", defined($options{"servername"}) ? "checked" : ""; print "<input size=10 name=smbfs_sname value=\"$options{servername}\"></td>\n"; } elsif ($smbfs_support == 2) { print "<tr> <td><b>Workgroup</b></td>\n"; printf "<td><input type=radio name=smbfs_wg_def value=1 %s> Automatic\n", defined($options{"workgroup"}) ? "" : "checked"; printf "<input type=radio name=smbfs_wg_def value=0 %s>\n", defined($options{"workgroup"}) ? "checked" : ""; print "<input size=10 name=smbfs_wg value=\"$options{'workgroup'}\"></td>\n"; } if ($smbfs_support != 3) { print "<td><b>Client Name</b></td>\n"; printf "<td><input type=radio name=smbfs_cname_def value=1 %s> Automatic\n", defined($options{"clientname"}) ? "" : "checked"; printf "<input type=radio name=smbfs_cname_def value=0 %s>\n", defined($options{"clientname"}) ? "checked" : ""; print "<input size=10 name=smbfs_cname value=\"$options{clientname}\"></td> </tr>\n"; print "<tr> <td><b>Server Address</b></td>\n"; printf "<td colspan=3><input type=radio name=smbfs_mname_def value=1 %s> Automatic\n", defined($options{"machinename"}) ? "" : "checked"; printf "<input type=radio name=smbfs_mname_def value=0 %s>\n", defined($options{"machinename"}) ? "checked" : ""; print "<input size=30 name=smbfs_mname value=\"$options{machinename}\"></td> </tr>\n"; } if ($smbfs_support == 1) { print "<tr> <td><b>File permissions</b></td>\n"; printf "<td><input name=smbfs_fmode size=5 value=\"%s\"></td>\n", defined($options{'fmode'}) ? $options{'fmode'} : "755"; print "<td><b>Directory permissions</b></td>\n"; printf "<td><input name=smbfs_dmode size=5 value=\"%s\"></td>\n", defined($options{'dmode'}) ? $options{'dmode'} : "755"; print "</tr>\n"; } elsif ($smbfs_support == 3) { print "<tr> <td><b>Read-only?</b></td>\n"; printf "<td><input type=radio name=lnx_ro value=1 %s> Yes\n", defined($options{"ro"}) ? "checked" : ""; printf "<input type=radio name=lnx_ro value=0 %s> No</td>\n", defined($options{"ro"}) ? "" : "checked"; print "</tr>\n"; } }}# check_location(type)# Parse and check inputs from %in, calling &error() if something is wrong.# Returns the location string for storing in the fstab filesub check_location{if ($_[0] eq "nfs") { local($out, $temp, $mout, $dirlist); # Use ping and showmount to see if the host exists and is up if ($in{nfs_host} !~ /^\S+$/) { &error("'$in{nfs_host}' is not a valid hostname"); } $out = `ping -c 1 '$in{nfs_host}' 2>&1`; if ($out =~ /unknown host/) { &error("The host '$in{nfs_host}' does not exist"); } elsif ($out =~ /100\% packet loss/) { &error("The host '$in{nfs_host}' is down"); } $out = `showmount -e '$in{nfs_host}' 2>&1`; if ($out =~ /Unable to receive/) { &error("The host '$in{nfs_host}' does not support NFS"); } elsif ($?) { &error("Failed to get mount list : $out"); } # Validate directory name foreach (split(/\n/, $out)) { if (/^(\/\S+)/) { $dirlist .= "$1\n"; } } if ($in{nfs_dir} !~ /^\/\S+$/) { &error("'$in{nfs_dir}' is not a valid directory name. The ". "available directories on $in{nfs_host} are:". "<pre>$dirlist</pre>"); } # Try a test mount to see if filesystem is available $temp = &tempname(); mkdir($temp, 0755); $mout = `mount $in{nfs_host}:$in{nfs_dir} $temp 2>&1`; if ($mout =~ /No such file or directory/) { rmdir($temp); &error("The directory '$in{nfs_dir}' does not exist on the ". "host $in{nfs_host}. The available directories are:". "<pre>$dirlist</pre>"); } elsif ($mout =~ /Permission denied/) { rmdir($temp); &error("This host is not allowed to mount the directory ". "$in{nfs_dir} from $in{nfs_host}"); } elsif ($?) { rmdir($temp); &error("NFS Error - $mout"); } # It worked! unmount `umount $temp`; rmdir($temp); return "$in{nfs_host}:$in{nfs_dir}"; }elsif ($_[0] eq "auto") { # Check if the automounter map exists.. (-r $in{auto_map}) || &error("The file '$in{auto_map}' does not exist"); return $in{auto_map}; }elsif ($_[0] eq "autofs") { # Check if the map exists (if it is a file) if ($in{'autofs_map'} =~ /^\// && !(-r $in{'autofs_map'})) { &error("The file '$in{autofs_map}' does not exist"); } return $in{autofs_map}; }elsif ($_[0] eq "smbfs") { # No checking done return "\\\\".lc($in{'smbfs_server'})."\\".lc($in{'smbfs_share'}); }else { # This is some kind of disk-based linux filesystem.. get the device name if ($in{'lnx_dev'} == 0) { $dv = $in{'lnx_disk'}; } else { $dv = $in{'lnx_other'}; $dv || &error("No device entered"); } # If the device entered is a symlink, follow it if ($dvlink = readlink($dv)) { if ($dvlink =~ /^\//) { $dv = $dvlink; } else { $dv =~ /^(.*\/)[^\/]+$/; $dv = $1.$dvlink; } } # Check if the device actually exists and uses the right filesystem if (!(-r $dv)) { if ($_[0] eq "swap" && $dv !~ /\/dev/) { &swap_form($dv); } else { &error("The device file '$dv' does not exist"); } } return $dv; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -