1 |
#!/bin/bash |
#!/bin/bash |
2 |
# Copyright 2002 Gentoo Technologies, Inc. |
# Copyright 1999-2004 Gentoo Foundation |
3 |
# Distributed under the terms of the GNU Public License v2 |
# Distributed under the terms of the GNU General Public License v2 |
4 |
|
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/etc-update,v 1.7 2005-10-26 08:11:30 niro Exp $ |
5 |
|
|
6 |
# Author Brandon Low <lostlogic@gentoo.org> |
# Author Brandon Low <lostlogic@gentoo.org> |
7 |
# |
# |
8 |
# Previous version (from which I've borrowed a few bits) by: |
# Previous version (from which I've borrowed a few bits) by: |
10 |
# Leo Lipelis <aeoo@gentoo.org> |
# Leo Lipelis <aeoo@gentoo.org> |
11 |
# Karl Trygve Kalleberg <karltk@gentoo.org> |
# Karl Trygve Kalleberg <karltk@gentoo.org> |
12 |
# |
# |
13 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/etc-update,v 1.6 2005-02-15 22:59:09 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/etc-update,v 1.7 2005-10-26 08:11:30 niro Exp $ |
14 |
|
|
15 |
# Modified by Niels Rogalla <niro@magellan-linux.de> to use this with Magellan-Linux |
# Modified by Niels Rogalla <niro@magellan-linux.de> to use this with Magellan-Linux |
16 |
# version: 0.3.6-r13 |
# version: 0.4.0-r8 |
17 |
|
|
18 |
export PORTAGE_CALLER="etc-update" |
export PORTAGE_CALLER="etc-update" |
19 |
|
|
24 |
# item. If there's more than one of the same configuration item, |
# item. If there's more than one of the same configuration item, |
25 |
# then allow the last setting to take precedence. |
# then allow the last setting to take precedence. |
26 |
cut -d'#' -f1-1 /etc/etc-update.conf | \ |
cut -d'#' -f1-1 /etc/etc-update.conf | \ |
27 |
sed -ne "s/^\ *$item\ *=\ *\"\(.*\)\"/\1/p" |sed -e '$p;d' |
sed -ne "s/^ *$item *= *\([\"']\{0,1\}\)\(.*\)\1/\2/p" |sed -e '$p;d' |
28 |
} |
} |
29 |
|
|
30 |
function scan() { |
function scan() { |
37 |
|
|
38 |
for path in ${CONFIG_PROTECT}; do if [ -d ${path} ]; then |
for path in ${CONFIG_PROTECT}; do if [ -d ${path} ]; then |
39 |
ofile="" |
ofile="" |
40 |
for file in `find ${path} -iname "._cfg????_*" | |
for file in `find ${path}/ -iname "._cfg????_*" | |
41 |
sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" | |
sed -e "s:\(^.*/\)\(\._cfg[0-9]*_\)\(.*$\):\1\2\3\%\2\%\3:" | |
42 |
sort -t'%' -k3 -k2 | cut -f1 -d'%'`; do |
sort -t'%' -k3 -k2 | LANG=POSIX LC_ALL=POSIX cut -f1 -d'%'`; do |
43 |
rpath=`echo "${file}" | sed -e "s:/[^/]*$::"` |
rpath=`echo "${file/\/\///}" | sed -e "s:/[^/]*$::"` |
44 |
rfile=`echo "${file}" | sed -e "s:^.*/::"` |
rfile=`echo "${file/\/\///}" | sed -e "s:^.*/::"` |
45 |
for mpath in ${CONFIG_PROTECT_MASK}; do |
for mpath in ${CONFIG_PROTECT_MASK}; do |
46 |
if [[ "${rpath}" == "${mpath}"* ]]; then |
if [[ "${rpath}" == "${mpath}"* ]]; then |
47 |
mv ${rpath}/${rfile} ${rpath}/${rfile:10} |
mv ${rpath}/${rfile} ${rpath}/${rfile:10} |
123 |
if (( ${mode} == 0 )); then |
if (( ${mode} == 0 )); then |
124 |
cat ${TMP}/menuitems |
cat ${TMP}/menuitems |
125 |
echo "Please select a file to edit by entering the corresponding number." |
echo "Please select a file to edit by entering the corresponding number." |
126 |
|
echo " (don't use -3 or -5 if you're unsure what to do)" |
127 |
echo " (-1 to exit) (-3 to auto merge all remaining files)" |
echo " (-1 to exit) (-3 to auto merge all remaining files)" |
128 |
echo -n " (-5 to auto-merge AND not use 'mv -i'): " |
echo -n " (-5 to auto-merge AND not use 'mv -i'): " |
129 |
read input |
read input |
192 |
if (( ${my_input} == 0 )); then |
if (( ${my_input} == 0 )); then |
193 |
my_input=1 |
my_input=1 |
194 |
elif (( ${my_input} == -1 )); then |
elif (( ${my_input} == -1 )); then |
195 |
|
input=0 |
196 |
return |
return |
197 |
elif (( ${my_input} == ${fcount} )); then |
elif (( ${my_input} == ${fcount} )); then |
198 |
break |
break |
263 |
case ${my_input} in |
case ${my_input} in |
264 |
1) echo "Replacing ${ofile} with ${file}" |
1) echo "Replacing ${ofile} with ${file}" |
265 |
mv ${mv_opts} ${file} ${ofile} |
mv ${mv_opts} ${file} ${ofile} |
266 |
|
my_input=-1 |
267 |
continue |
continue |
268 |
;; |
;; |
269 |
2) echo "Deleting ${file}" |
2) echo "Deleting ${file}" |
355 |
|
|
356 |
trap die term |
trap die term |
357 |
|
|
358 |
TMP=/tmp/$$ |
TMP="/tmp/$$" |
359 |
rm -rf ${TMP} 2> /dev/null |
rm -rf ${TMP} 2> /dev/null |
360 |
mkdir ${TMP} || die "failed mkdir command!" 1 |
mkdir ${TMP} || die "failed mkdir command!" 1 |
361 |
|
|
362 |
# I need the CONFIG_PROTECT value |
# I need the CONFIG_PROTECT value |
363 |
#CONFIG_PROTECT=$(/usr/lib/portage/bin/portageq config_protect) |
#CONFIG_PROTECT=$(/usr/lib/portage/bin/portageq config_protect) |
364 |
#CONFIG_PROTECT_MASK=$(/usr/lib/portage/bin/portageq config_protect_mask) |
#CONFIG_PROTECT_MASK=$(/usr/lib/portage/bin/portageq config_protect_mask) |
|
#source /etc/CONFIG_PROTECT |
|
365 |
source /etc/profile |
source /etc/profile |
366 |
|
|
367 |
# load etc-config's configuration |
# load etc-config's configuration |
384 |
PAR=")" |
PAR=")" |
385 |
else |
else |
386 |
PAR="" |
PAR="" |
|
rm_opts="" |
|
|
mv_opts="" |
|
|
cp_opts="" |
|
|
pager=""P |
|
387 |
fi |
fi |
388 |
|
|
389 |
declare -i count=0 |
declare -i count=0 |