#!/bin/sh # version: 0.3.6-r9 # # rebuilds /etc/{ld.so.conf,profile.env} with given files from /etc/env.d # ## # exp. /etc/env.d/kde # # PATH="/opt/kde/bin" # ROOTPATH="/opt/kde/bin" # LDPATH="/opt/kde/lib" # ## #sets root path P="" SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CONFIG_PROTECT CONFIG_PROTECT_MASK PRELINK_PATH PRELINK_PATH_MASK" #SPECIALVARS="KDEDIRS PATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CLASSPATH" echo -en "\n>>>> Rebuilding environment... " #deletes existing conf files if [ -f ${P}/etc/ld.so.conf ] then rm ${P}/etc/ld.so.conf fi if [ -f ${P}/etc/profile.env ] then rm ${P}/etc/profile.env fi #gets everything in /etc/env.d for file in ${P}/etc/env.d/* do #reads content of every file while read path do if [ -n "$path" ] then #writes LDPATH to ${P}/etc/ld.so.conf, #anything else to ${P}/etc/profile.env if [ "${path%%=*}" == LDPATH ] then #substitudes " from $path if exists path="${path//\"}" echo "${path##*=}" >> ${P}/etc/ld.so.conf else #checks if var exists in specialvars for i in $SPECIALVARS do if [ "${path%%=*}" == "$i" ] then SPECVAR="yes" fi done if [ "$SPECVAR" == "yes" ] then if [ "${path%%=*}" == "CONFIG_PROTECT" -o "${path%%=*}" == "CONFIG_PROTECT_MASK" ] then #CONFIG_PROTECTS has as delimiter not ':' but ' ' path="${path//\"}" echo -n "${path##*=} " >> /var/tmp/${path%%=*} unset SPECVAR else #special var are written to tmpfile # to substitude them to one variable #substitudes " from $path if exists path="${path//\"}" echo -n "${path##*=}:" >> /var/tmp/${path%%=*} unset SPECVAR fi else #all other vars go directly to /etc/profile.env echo "export $path" >> ${P}/etc/profile.env fi fi fi done << EOF $(cat $file) EOF done #reads special vars tmp files and writes them to /etc/profile.env for i in $SPECIALVARS do if [ -f /var/tmp/${i} ] then echo "export ${i}=\"`cat /var/tmp/${i}`\"" >> ${P}/etc/profile.env rm /var/tmp/${i} fi done #rebuilds environment ldconfig source ${P}/etc/profile echo -e "done.\n"