Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../.././../lib/svc/method/fs-minimal
Real path: /lib/svc/method/fs-minimal
Zurück
#!/usr/bin/ksh # # Copyright (c) 1992, 2023, Oracle and/or its affiliates. # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. # All rights reserved. # # . /lib/svc/share/smf_include.sh . /lib/svc/share/fs_include.sh PATH=/usr/bin:/usr/sbin function remounttmp { readvfstab /tmp < $vfstab vfstab_mntopts="$mntopts" if [ -z "$mountp" ]; then if mounted /tmp - - < /etc/mnttab ; then return else print "WARNING /tmp not mounted or in /etc/vfstab" exit $SMF_EXIT_ERR_CONFIG fi fi if ! mounted $mountp - $fstype < /etc/mnttab ; then mountfs - $mountp $fstype $vfstab_mntopts $special [ $? -eq 0 ] || exit $SMF_EXIT_ERR_FATAL return fi # Don't remount if there are no options in vfstab and we just # have the default mount options for tmpfs default=${mntopts%%xattr,dev=*} if [ "$default" = "" -a "$vfstab_mntopts" = "-" ]; then return fi print "Remounting /tmp to apply $vfstab_mntopts" mountfs - $mountp $fstype remount,$vfstab_mntopts $special [ $? -eq 0 ] || exit $SMF_EXIT_ERR_FATAL } function varshare_create_err { # We have not been able to create or mount the shared dataset, passed # as the first argument, on the location passed as the second. Or we # have not migrated contents from the location passed as the third # argument. This is severe enough to cause us to exit with an error. print "" print "Unable to create dataset $1 or mount it on $2." print "Please move any existing content from $2 to " print "$3, ensure that $2 is an empty directory," print "then run the following commands:" print "/usr/sbin/zfs create -o canmount=noauto -o mountpoint=$2 $1" print "/usr/sbin/zfs mount $1" print "/lib/svc/share/migrate_shared_files.py $3 $2 $SMF_FMRI" print "" exit $SMF_EXIT_ERR_FATAL } # # This functions mounts dataset and returns 0 when the dataset is # mounted or is already mounted and returns 1 when the dataset does # not exist. If mounting the dataset fails, we exit with an error. # function mount_if_defined { if zfs list -Ho mountpoint "$1" > /dev/null 2>&1; then if ! mounted "$2" - zfs < /etc/mnttab; then if ! zfs mount "$1"; then exit $SMF_EXIT_ERR_FATAL fi fi return 0 else return 1 fi } # # Setup /var/share using /var/.migrate and add some needed symlinks. # function initialize_varshare { if [[ ! -L /var/share/tmp ]]; then ln -s ../tmp /var/share/tmp fi # If lastlog hasn't been migrated, move it now; as it is # not packaged, we need to do this by hand. Also, we can not # package the symbolic link so we create that here too. # The file may not exist and so we ignore errors from mv(1). if [[ ! -L /var/adm/lastlog ]]; then if [[ ! -f /var/share/adm/lastlog ]]; then mv /var/adm/lastlog /var/.migrate/adm 2>/dev/null fi rm -f /var/adm/lastlog ln -s ../share/adm/lastlog /var/adm/lastlog fi # Migrate content to /var/share if required /lib/svc/share/migrate_shared_files.py /var/.migrate \ /var/share $SMF_FMRI > /dev/console } # Create a new data set under rpool/VARSHARE to replace an existing # subdirectory and optionally migrate data from the old directory in # to the new data set. # # $1 is the name of the dataset # $2 is the name of the mount point # $3 if set is the name of a location to move the old data to. # # If $3 is set we simply move the old directory there, if not we # migrate the data function subdir_to_dataset { migrate=0 if [ -z "$3" ]; then dest=/var/share/.migrate migrate=1 else dest=$3 fi if [ ! -d $dest ]; then mkdir $dest fi mv $2/* $dest rmdir $2 # Inherit the properties from rpool/VARSHARE as # that is what existed before. zfs create $1 if [ $? != 0 ] ; then varshare_create_err $1 $2 $dest fi chmod 700 $2 # Set the compression to lz4 if the zpool version supports it. # lz4 offers the best balance of compression speed and # space utilization. rpool_version=$(zpool get -H -o value version $rpool) if [ $rpool_version -ge 37 ]; then zfs set compression=lz4 $1 fi # We set canmount to noauto or old BEs will find a failure in # filesystem/local. We do this after creating the file system # so we don't have to mount it by hand after creation. zfs set canmount=noauto $1 # Migrate content to /var/share if required if [ $migrate == 1 ]; then /lib/svc/share/migrate_shared_files.py $dest \ /var/share/ $SMF_FMRI > /dev/console fi } # /tmp should have been mounted by the kernel, but if the admin has customised # /etc/vfsab to list a size restriction it needs to be remounted remounttmp # Create volatile-user and the root user's volatile-user directory. # The root account might not login and we may need to store things such # as a Kerberos cred cache. # For normal users pam_unix_cred would create their /tmp/volatile-user # directory during pam_set_cred(). mkdir -m 700 -p /tmp/volatile-user/0 chmod "S+v{nounlink}" /tmp/volatile-user # Create the librt directories; /tmp/.LIBRT gets to be immutable. mkdir -p -m 1777 /tmp/.LIBRT/{SEMD,SEML,MQD,MQP,MQN,MQL,SHM} chmod "S+v{immutable}" /tmp/.LIBRT # In a zone, the zone root is mounted with a temporary mountpoint option # (zfs mount -o mountpoint=<dir> <dataset>). If the mountpoint of a child # dataset is inherited, neither "zfs mount <dataset>" nor "zfs mount -a" # will cause that child dataset to be mounted. That is, the only way to # mount such a child is with a temporary mountpoint option. Thus, if the # root (zone root, that is) file system is mounted with a temporary # mountpoint option, we also need to mount other datasets in the BE # using a temporary mountpoint. rootiszfs=0 rootistmpmnt=0 readmnttab / < /etc/mnttab if [ "$fstype" = zfs ] ; then rootiszfs=1 be=$special rpool=${be%%/*} case "$mntopts" in *mountpoint=*) rootistmpmnt=1 ;; esac fi # Everything else in this method only applies to ZFS root # since it is all to do with things under /var and the VARSHARE dataset. # Or updating the last boot-time on the ZFS root. if [ "$rootiszfs" = 0 ]; then mount_shared # Populate /var/share from /var/.migrate even in the miniroot. if [[ -w /var/share ]]; then # In ZFS root the directory is created automatically. mkdir -p /var/tmp initialize_varshare fi exit $SMF_EXIT_OK fi # Updating the last boot time property if booted r/w if [[ -w / ]]; then # Set Boot Timestamp now=$(TZ=UTC date +%Y%m%dT%H%M%SZ) zfs set com.oracle.libbe:last-boot-time="$now" "$be" fi # Mount other file systems to be available in single user mode, those # are any ZFS filesystem below the BE. zfs list -rH -o mountpoint -s mountpoint -t filesystem \ "$be" 2> /dev/null | \ while read mountp ; do if [ "$mountp" != "" -a "$mountp" != "legacy" ] ; then mounted $mountp - zfs < /etc/mnttab && continue opts= if [ $rootistmpmnt = 1 ]; then opts="$opts -o mountpoint=$mountp" fi zfs mount $opts $be$mountp fi done mount_if_defined "$rpool/VARSHARE" /var/share if is_self_assembly_boot; then # For directories under /var that we wish to share across boot # environments, we must ensure that our shared dataset exists, then # must migrate any salvaged files and directories over to that dataset. if ! mounted /var/share - zfs < /etc/mnttab ; then fsname="$rpool/VARSHARE" compression="" if mounted /var - zfs < /etc/mnttab ; then compression=$(zfs get -H -o value compression $be/var) if [ $? = 0 ]; then compression="-o compression=$compression" fi fi zfs create -o canmount=noauto \ -o setuid=off -o exec=off -o xattr=off \ -o mountpoint=/var/share $compression $fsname if [ $? != 0 ] ; then varshare_create_err $fsname /var/share /var/.migrate fi zfs mount $fsname if [ $? != 0 ] ; then varshare_create_err $fsname /var/share /var/.migrate fi else # VARSHARE already existed but we may need to update the # setuid/exec/xattr properties and owner/permission chown root:root /var/share chmod 0755 /var/share fsname="$rpool/VARSHARE" props=setuid,exec,xattr zfs get -Hp -o property,value $props $fsname| \ while read prop val ; do if [ $val = "on" ]; then zfs set $prop=off $fsname fi done unset props fi fsname="$rpool/VARSHARE/tmp" if ! mount_if_defined $fsname /var/tmp; then # # Create /var/tmp; the default was always # exec,setuid,xattr so we create it with these properties. # We do not enforce it and give the customer the ability to # change it. # zfs create -o setuid=on -o exec=on -o xattr=on \ -o mountpoint=/var/tmp $fsname if [ $? != 0 ] ; then varshare_create_err $fsname /var/tmp /var/.migrate fi # # We set canmount to noauto or old BEs will find a failure in # filesystem/local. We do this after creating the file system # so we don't have to mount it by hand after creation. # zfs set canmount=noauto $fsname fi initialize_varshare else # Make sure /var/tmp is available when this service is online. mount_if_defined "$rpool/VARSHARE/tmp" /var/tmp fi # Migrate /var/user to new style /lib/svc/share/migrate_var_user.py # Now that VARSHARE is created and mounted, ensure the kvol container # exists, and tell the kernel to initialise kvols if smf_is_globalzone; then if ! mount_if_defined ${rpool}/VARSHARE/kvol /var/share/kvol; then zfs create ${rpool}/VARSHARE/kvol fi /usr/lib/kvoltool if [ $? != 0 ] ; then exit $SMF_EXIT_ERR_FATAL fi # If it is already created, mount it here else leave it to the # zone restarter. # # A workaround for a regression where in a few 11.3 SRU updates we # failed to mount the dataset resulting in zone directories being # created directly in the rpool dataset. Non-empty /system/zones would # prevent mounting its dataset if we did not remove the directories now. sz_mntpoint=/system/zones sz_dataset=$rpool/VARSHARE/zones sz_mounted=$(zfs get -H -o value mounted $sz_dataset 2>/dev/null) if [[ $? == 0 && "$sz_mounted" == "no" ]]; then if ls $sz_mntpoint/* 2>/dev/null 1>&2; then rmdir $sz_mntpoint/* if [[ $? != 0 ]]; then exit $SMF_EXIT_ERR_FATAL fi fi fi mount_if_defined $sz_dataset $sz_mntpoint if is_self_assembly_boot; then # Install the zone index from uar or create an empty version. zindex=/var/share/zones/index.json zuindex=/etc/zones/index-uar.json if [[ -f $zindex ]]; then rm -f $zuindex else if [[ -f $zuindex ]]; then mv -f $zuindex $zindex else print "[]" > $zindex fi chmod 0644 $zindex fi fi fi # If this is not a zfs storage appliance, we want to create separate # file systems for core files and if appropriate, crash dumps. if [[ $(getconf _SC_SUNW_FEATURE_AK) == 0 ]]; then fsname="$rpool/VARSHARE/cores" if ! mount_if_defined $fsname /var/share/cores; then subdir_to_dataset $fsname /var/share/cores fi if smf_is_globalzone; then fsname="$rpool/VARSHARE/crash" if ! mount_if_defined $fsname /var/share/crash; then subdir_to_dataset $fsname /var/share/crash \ /var/share/historical-crash fi fi fi mount_shared exit $SMF_EXIT_OK