author  Norm Jacobs <Norm.Jacobs@Oracle.COM> 
Fri, 14 Oct 2011 15:51:54 0700  
changeset 536  cc30c1136ebb 
parent 221  a82f927119a1 
child 559  5ec27e888a6e 
permissions  rwrr 
221
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

1 
#!/bin/bash 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

2 
# 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

3 
# CDDL HEADER START 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

4 
# 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

5 
# The contents of this file are subject to the terms of the 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

6 
# Common Development and Distribution License (the "License"). 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

7 
# You may not use this file except in compliance with the License. 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

8 
# 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

9 
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

10 
# or http://www.opensolaris.org/os/licensing. 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

11 
# See the License for the specific language governing permissions 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

12 
# and limitations under the License. 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

13 
# 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

14 
# When distributing Covered Code, include this CDDL HEADER in each 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

15 
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

16 
# If applicable, add the following below this CDDL HEADER, with the 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

17 
# fields enclosed by brackets "[]" replaced with your own identifying 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

18 
# information: Portions Copyright [yyyy] [name of copyright owner] 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

19 
# 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

20 
# CDDL HEADER END 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

21 
# 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

22 

a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

23 
# 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

24 
# Copyright (c) 2011, Oracle and/or it's affiliates. All rights reserved. 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

25 
# 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

26 

a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

27 
. /lib/svc/share/smf_include.sh 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

28 

a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

29 
TEXINFO_DATA_DIR="/var/info" 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

30 

a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

31 
function populate_texinfo_directory() { 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

32 
directory=$(dirname $1) 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

33 
dir_file=$(readlink f $1) 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

34 

a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

35 
[[ ${dir_file} ot ${directory} ]]  return 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

36 

a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

37 
case "${dir_file}" in 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

38 
/var/info/*) # Only process if the link resolves inside /var/info. 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

39 
echo "populating ${dir_file} from ${directory}" 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

40 
/bin/rm f ${dir_file}.new 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

41 
for info_file in $(find ${directory} type f  \ 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

42 
egrep v e '[09]+$') ; do 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

43 
/usr/bin/installinfo dirfile=${dir_file}.new \ 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

44 
infofile=${info_file} 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

45 
done 
536
cc30c1136ebb
7092164 application/texinfoupdate's start method needs improvement
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
221
diff
changeset

46 
owner_group='root:bin' # default owner/group 
cc30c1136ebb
7092164 application/texinfoupdate's start method needs improvement
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
221
diff
changeset

47 
if [[ f ${dir_file} ]] ; then 
cc30c1136ebb
7092164 application/texinfoupdate's start method needs improvement
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
221
diff
changeset

48 
# get owner/group from original file 
cc30c1136ebb
7092164 application/texinfoupdate's start method needs improvement
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
221
diff
changeset

49 
group_bin=$(/bin/ls l ${dir_file}  \ 
cc30c1136ebb
7092164 application/texinfoupdate's start method needs improvement
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
221
diff
changeset

50 
awk '{print $3":"$4}') 
cc30c1136ebb
7092164 application/texinfoupdate's start method needs improvement
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
221
diff
changeset

51 
fi 
221
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

52 
/bin/mv f ${dir_file}.new ${dir_file} 
536
cc30c1136ebb
7092164 application/texinfoupdate's start method needs improvement
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
221
diff
changeset

53 
/bin/chmod f 0644 ${dir_file} 
cc30c1136ebb
7092164 application/texinfoupdate's start method needs improvement
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
221
diff
changeset

54 
/bin/chown f ${owner_group} ${dir_file} 
221
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

55 
/bin/ln s ${1} ${dir_file}.backlink 2>/dev/null 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

56 
;; 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

57 
esac 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

58 
} 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

59 

a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

60 
### Begin Here ### 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

61 

a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

62 
case "$1" in 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

63 
'start''refresh') 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

64 
# refresh texinfo directories 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

65 
for dir_link in $(pkg search H l o path ':link:path:*/info/dir'  \ 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

66 
sort u) ; do 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

67 
populate_texinfo_directory /${dir_link} 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

68 
done 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

69 
# remove any unreferenced directories 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

70 
for link in $(find ${TEXINFO_DATA_DIR} type l name '*.backlink') ; do 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

71 
path=$(readlink ${link}) 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

72 
if [[ ! L ${path} ]] ; then 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

73 
file=$(expr "${link}" : "\(.*\)\.backlink") 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

74 
echo n "removing unreferenced texinfo directory: " 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

75 
echo "${file} ${link}" 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

76 
/bin/rm f ${file} ${link} 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

77 
fi 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

78 
done 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

79 
;; 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

80 
*) 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

81 
echo "Usage: $0 (startrefresh)" 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

82 
exit 1 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

83 
;; 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

84 
esac 
a82f927119a1
7017805 texinfo should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset

85 
exit $SMF_EXIT_OK 