Annotation of /trunk/mage/usr/lib/mage/env-rebuild.sh
Parent Directory | Revision Log
Revision 78 -
(hide annotations)
(download)
(as text)
Wed Jun 1 15:48:52 2005 UTC (19 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 2465 byte(s)
Wed Jun 1 15:48:52 2005 UTC (19 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 2465 byte(s)
changed version tagging only
1 | niro | 24 | #!/bin/sh |
2 | |||
3 | niro | 78 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/env-rebuild.sh,v 1.7 2005-06-01 15:48:11 niro Exp $ |
4 | niro | 24 | # |
5 | # rebuilds /etc/{ld.so.conf,profile.env} with given files from /etc/env.d | ||
6 | # | ||
7 | |||
8 | ## | ||
9 | # exp. /etc/env.d/kde | ||
10 | # | ||
11 | # PATH="/opt/kde/bin" | ||
12 | # ROOTPATH="/opt/kde/bin" | ||
13 | # LDPATH="/opt/kde/lib" | ||
14 | # | ||
15 | ## | ||
16 | |||
17 | #sets root path | ||
18 | P="" | ||
19 | niro | 55 | SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CONFIG_PROTECT CONFIG_PROTECT_MASK PRELINK_PATH PRELINK_PATH_MASK OMF_DIR" |
20 | niro | 24 | #SPECIALVARS="KDEDIRS PATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CLASSPATH" |
21 | |||
22 | echo -en "\n>>>> Rebuilding environment... " | ||
23 | |||
24 | #deletes existing conf files | ||
25 | if [ -f ${P}/etc/ld.so.conf ] | ||
26 | then | ||
27 | rm ${P}/etc/ld.so.conf | ||
28 | fi | ||
29 | |||
30 | if [ -f ${P}/etc/profile.env ] | ||
31 | then | ||
32 | rm ${P}/etc/profile.env | ||
33 | fi | ||
34 | |||
35 | #gets everything in /etc/env.d | ||
36 | for file in ${P}/etc/env.d/* | ||
37 | do | ||
38 | #reads content of every file | ||
39 | while read path | ||
40 | do | ||
41 | if [ -n "$path" ] | ||
42 | then | ||
43 | #writes LDPATH to ${P}/etc/ld.so.conf, | ||
44 | #anything else to ${P}/etc/profile.env | ||
45 | if [ "${path%%=*}" == LDPATH ] | ||
46 | then | ||
47 | #substitudes " from $path if exists | ||
48 | path="${path//\"}" | ||
49 | echo "${path##*=}" >> ${P}/etc/ld.so.conf | ||
50 | else | ||
51 | #checks if var exists in specialvars | ||
52 | for i in $SPECIALVARS | ||
53 | do | ||
54 | if [ "${path%%=*}" == "$i" ] | ||
55 | then | ||
56 | SPECVAR="yes" | ||
57 | fi | ||
58 | done | ||
59 | |||
60 | if [ "$SPECVAR" == "yes" ] | ||
61 | then | ||
62 | if [ "${path%%=*}" == "CONFIG_PROTECT" -o "${path%%=*}" == "CONFIG_PROTECT_MASK" ] | ||
63 | then | ||
64 | #CONFIG_PROTECTS has as delimiter not ':' but ' ' | ||
65 | path="${path//\"}" | ||
66 | echo -n "${path##*=} " >> /var/tmp/${path%%=*} | ||
67 | unset SPECVAR | ||
68 | else | ||
69 | #special var are written to tmpfile | ||
70 | # to substitude them to one variable | ||
71 | #substitudes " from $path if exists | ||
72 | path="${path//\"}" | ||
73 | echo -n "${path##*=}:" >> /var/tmp/${path%%=*} | ||
74 | unset SPECVAR | ||
75 | fi | ||
76 | else | ||
77 | #all other vars go directly to /etc/profile.env | ||
78 | echo "export $path" >> ${P}/etc/profile.env | ||
79 | fi | ||
80 | fi | ||
81 | fi | ||
82 | done << EOF | ||
83 | $(cat $file) | ||
84 | EOF | ||
85 | |||
86 | done | ||
87 | |||
88 | #reads special vars tmp files and writes them to /etc/profile.env | ||
89 | for i in $SPECIALVARS | ||
90 | do | ||
91 | if [ -f /var/tmp/${i} ] | ||
92 | then | ||
93 | niro | 55 | # only OMF_DIR goes to /etc/scrollkeeper.conf |
94 | if [[ ${i} = OMF_DIR ]] | ||
95 | then | ||
96 | echo "${i}=`cat /var/tmp/${i}`" > ${P}/etc/scrollkeeper.conf | ||
97 | else | ||
98 | echo "export ${i}=\"`cat /var/tmp/${i}`\"" >> ${P}/etc/profile.env | ||
99 | fi | ||
100 | niro | 24 | rm /var/tmp/${i} |
101 | fi | ||
102 | done | ||
103 | |||
104 | #rebuilds environment | ||
105 | ldconfig | ||
106 | source ${P}/etc/profile | ||
107 | |||
108 | echo -e "done.\n" |
Properties
Name | Value |
---|---|
svn:executable | * |