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