source: src-sh/pbi-manager10/pbime/pbimount @ 8a3e12a

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1
Last change on this file since 8a3e12a was 8a3e12a, checked in by Kris Moore <kris@…>, 13 months ago

Update pbi-manager10, now we add rc.d wrappers and will create
links in /usr/pbi/etc/rc.d for them.

  • Property mode set to 100755
File size: 3.7 KB
Line 
1#!/bin/sh
2
3NULLFS="/usr/pbi/.mount_nullfs"
4
5is_mounted() {
6   mount | grep -q "on ${1} (" 
7   return $?
8}
9
10check_pbidir() {
11  if [ -d "${1}/pbimeta" ] ; then return ; fi
12  echo "Error: Invalid PBI: ${1}"
13  exit 1
14}
15
16get_pdir() {
17  pDir="${1}"
18  if [ ! -d "${pDir}/virtbase" ] ; then
19    mkdir -p ${pDir}/virtbase
20  fi
21  if [ ! -d "${pDir}/run" ] ; then
22    mkdir -p ${pDir}/run
23  fi
24}
25
26mount_pbifile() {
27   if [ ! -d "$pDir" ] ; then
28      mkdir -p "${pDir}"
29   else
30      # Check to see if it is already mounted
31      mount | grep -q "on ${pDir} (ufs,"
32      if [ $? -eq 0 ] ; then return; fi
33   fi
34   MD=`mdconfig -a -t vnode -f ${1}`
35   mount -r -t ufs /dev/${MD}.uzip "${pDir}"
36}
37
38mount_dirs() {
39   is_mounted "${pDir}/virtbase" || $NULLFS / ${pDir}/virtbase
40   is_mounted "${pDir}/virtbase/dev" || mount -t devfs devfs ${pDir}/virtbase/dev
41   is_mounted "${pDir}/virtbase/usr/local" || $NULLFS ${1}/local ${pDir}/virtbase/usr/local
42   is_mounted "${pDir}/virtbase/var/run" || mount -t unionfs -o noatime ${pDir}/run ${pDir}/virtbase/var/run
43   is_mounted "${pDir}/virtbase/usr/local/etc" || mount -t unionfs -o noatime ${1}/etc ${pDir}/virtbase/usr/local/etc
44   is_mounted "${pDir}/virtbase/compat/linux" || $NULLFS ${1}/linux ${pDir}/virtbase/compat/linux
45   if [ -d "${pDir}/virtbase/usr/local/etc/fonts" ] ; then
46      is_mounted "${pDir}/virtbase/usr/local/etc/fonts" || $NULLFS /usr/local/etc/fonts ${pDir}/virtbase/usr/local/etc/fonts
47   fi
48   if [ -d "${pDir}/virtbase/usr/local/lib/X11/fonts" ] ; then
49      is_mounted "${pDir}/virtbase/usr/local/lib/X11/fonts" || $NULLFS /usr/local/lib/X11/fonts ${pDir}/virtbase/usr/local/lib/X11/fonts
50   fi
51   if [ -d "${pDir}/virtbase/usr/local/lib/X11/icons" ] ; then
52      is_mounted "${pDir}/virtbase/usr/local/lib/X11/icons" || $NULLFS /usr/local/lib/X11/icons ${pDir}/virtbase/usr/local/lib/X11/icons
53   fi
54   is_mounted "${pDir}/virtbase/tmp" || $NULLFS /tmp ${pDir}/virtbase/tmp
55   is_mounted "${pDir}/virtbase/usr/home" || $NULLFS /usr/home ${pDir}/virtbase/usr/home
56   for i in `ls -d /usr/home/* 2>/dev/null`
57   do
58      is_mounted "${i}" 
59      if [ $? -eq 0 ] ;then
60         is_mounted "${pDir}/virtbase${i}" || $NULLFS ${i} ${pDir}/virtbase${i}
61      fi
62
63   done
64
65   chroot ${pDir}/virtbase /etc/rc.d/ldconfig start >/dev/null 2>/dev/null
66}
67
68umount_pbidir() {
69   is_mounted "${pDir}/virtbase/usr/local/etc/fonts" && umount ${pDir}/virtbase/usr/local/etc/fonts
70   is_mounted "${pDir}/virtbase/usr/local/etc" && umount ${pDir}/virtbase/usr/local/etc
71   is_mounted "${pDir}/virtbase/usr/local/lib/X11/fonts" && umount ${pDir}/virtbase/usr/local/lib/X11/fonts
72   is_mounted "${pDir}/virtbase/usr/local/lib/X11/icons" && umount ${pDir}/virtbase/usr/local/lib/X11/icons
73   is_mounted "${pDir}/virtbase/usr/local" && umount ${pDir}/virtbase/usr/local
74   is_mounted "${pDir}/virtbase/tmp" && umount ${pDir}/virtbase/tmp
75   is_mounted "${pDir}/virtbase/dev" && umount ${pDir}/virtbase/dev
76   is_mounted "${pDir}/virtbase/var/run" && umount ${pDir}/virtbase/var/run
77   is_mounted "${pDir}/virtbase/compat/linux" && umount ${pDir}/virtbase/compat/linux
78   for i in `ls -d ${pDir}/virtbase/usr/home/* 2>/dev/null`
79   do
80      is_mounted "${i}" && umount ${i}
81   done
82   is_mounted "${pDir}/virtbase/usr/home" && umount ${pDir}/virtbase/usr/home
83   is_mounted "${pDir}/virtbase" && umount ${pDir}/virtbase
84}
85
86
87# Doing an unmount?
88if [ "$1" = "umount" ] ; then
89   get_pdir "$2"
90   umount_pbidir "$2"
91   exit 0
92fi
93
94if [ -z "$1" -o -z "$2" ] ; then
95   echo "Missing args: mountdir / pbidir"
96   exit 1
97fi
98
99MNTBASEDIR="`dirname $2`"
100
101if [ ! -d "$MNTBASEDIR" ] ; then
102   mkdir -p ${MNTBASEDIR}
103   echo "Do not manually remove this directory!" > ${MNTBASEDIR}/DONOTDELETE
104fi
105
106# Lets begin the mount process
107get_pdir "$1"
108check_pbidir "${2}"
109mount_dirs "${2}"
Note: See TracBrowser for help on using the repository browser.