-
Senior Member
registered user
folderconfig - easy configuration system using diff
Hi all,
I am working on a configuration system that uses "diff" for saving the differences in configuration files. Essentially, you start a script, make your modifications to knoppix files as you want, you re-run the script, and the differences are saved to diff files.
Upon boot, the diffs are applied to the corresponding (configuration) files.
Currently, I have it working well but only when burned to CD-ROM or used from HD with "poor man's install".
The script is as follows. It works for my purposes but is far from perfect. (Where are the script wizzzards?)
Code:
#!/bin/sh
# folderconfigurator 1.0
# Creates a folderconfig directory
# by probono
# GPL
############################################
# currently /cdrom hardcoded -> how to change?
############################################
#
# define some variables
#
# temporary folderconfig directory
export FOLDERCONFIG="/tmp/folderconfig/"
# where the knoppix.sh script is created
export TMPKNOPPIXSH="/tmp/knoppix.sh"
#
# if there is no folderconfig directory yet
#
# create one
if [ ! -e $FOLDERCONFIG ]
then
kdialog --msgbox "Please start changing your configuration now. \n Only (diffs of) configuration files that are changed between now and the time when you will re-run this script will be saved in the $FOLDERCONFIG directory. Please re-run this script as soon as you are done with configuring the system." && mkdir $FOLDERCONFIG
exit 0
#
# if there is alredy a folderconfig directory
#
else
kdialog --yesnocancel "Now copying the (diffs of) files that were changed since the creation of $FOLDERCONFIG to that directory." || exit 0
##################################################################
#
# create the folderconfig knoppix.sh script
#
cat > $TMPKNOPPIXSH << \EOF
#!/bin/sh
# folderconfig 1.0
# Copies the contents of a folderconfig directory into the running system
# by probono
# GPL
[ "`id -u`" = "0" ] || { echo "You need root privileges to apply folderconfig settings!" >&2 ; exit 1; }
echo " [1mApplying folderconfig settings... [0m"
# copy normal files, follow symlinks in target
cp -rfH $1/folderconfig/* /
# fix bug(?) that I cannot create a folder named X11 (it always gets x11)
if [ -e "/etc/x11/" ]; then
cp -rfH /etc/x11/* /etc/X11
fi
# patch file if there is a .diff for the file
find /cdrom/knoppix/folderconfig/* -type f -name "*.diff" | while read i; do target="${i#/cdrom/knoppix/folderconfig}"; target="${target%.diff}"; patch $target $i; done
# set access rights of home directory
chown -R $USER.$USER $HOME
EOF
##################################################################
# find files and symlinks that have been changed after the folderconfig folder was created
# ignore these self-changing files
FILES=`find /etc /home /root -follow \
! -path *ld.so.cache \
! -path *pnm2ppa.conf* \
! -path *gnome-desktop* \
! -path *ld.so.cache* \
! -path *.xsession-errors* \
! -path *.fonts-cache-1* \
-newer $FOLDERCONFIG -type f \
2> /dev/null`
# if there are no files that have changed
if [ "$FILES" = "" ]
then
kdialog --msgbox "No files found that have changed."
exit 1
fi
#
# create parent folders
#
#for FILE in $FILES; do echo $FILE; done; echo "\n\n"
for FILE in $FILES; do DIR=`find $FILE -printf "%h\n"`; mkdir -p $FOLDERCONFIG$DIR; done
#
# make a diff (for the changed files) or copy the file (for new files)
#
# works # for FILE in $FILES; do diff -u /KNOPPIX$FILE $FILE > $FOLDERCONFIG$FILE.diff ; done
for FILE in $FILES
do
if [ -e /KNOPPIX$FILE ]; then
diff -u /KNOPPIX$FILE $FILE > $FOLDERCONFIG$FILE.diff
else
cp $FILE $FOLDERCONFIG$FILE
fi
done
# make it executable
chmod 777 $TMPKNOPPIXSH
kdialog --msgbox "The (diffs of) files that have changed since the initial creation of $FOLDERCONFIG have now been saved to $FOLDERCONFIG. \n You can use the script $TMPKNOPPIXSH to copy them to your Live-CD system automatically at each start of the system. Please refer to the Knoppix documentation on how to use a knoppix.sh script. Essentially, you must copy $TMPKNOPPIXSH and $FOLDERCONFIG to a floppy and use floppyconfig or burn them to the knoppix/ directory on your CD-ROM."
# all is ok
exit 0
fi
Similar Threads
-
By star in forum Customising & Remastering
Replies: 0
Last Post: 04-26-2005, 04:29 AM
-
By joekrahn in forum Ideas
Replies: 1
Last Post: 02-24-2004, 05:20 PM
-
By zkosty in forum General Support
Replies: 4
Last Post: 10-22-2003, 06:13 PM
-
By holzhey in forum Customising & Remastering
Replies: 3
Last Post: 02-13-2003, 06:15 PM
-
By freyley in forum Hdd Install / Debian / Apt
Replies: 1
Last Post: 01-31-2003, 09:21 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules

Lenovo ThinkStation P520c Intel Xeon W-2133 6-Core 3.60GHz -NO RAM/ HDD/ GPU/ OS
$127.54

Intel Xeon Phi 5110P 60-Core 1.053GHz Coprocessor
$50.00

Dell EMC PowerEdge R440 Xeon silver 4215 2.5GHz 16 GB ram 2x 550W PSU No HDD
$275.00

Dell Precision T1700 Workstation Intel Xeon 16G Ram 256GG SSD Nvidia 600 Win 10
$109.99

Intel Xeon E5-2680 V2 2.8GHz 10-Core 25MB 8GT/s SR1A6 LGA2011 B Grade Server CPU
$7.95

Intel Xeon E5-2699 V4 2.20GHz 55M 22-CORES LGA2011-3 Server Processor 145W SR2JS
$84.49

Dell Precision T5820 Workstation 3.70GHz W-2135 No RAM/ GPU/ HDD/ OS
$179.98

Dell Precision T7820 2x Xeon Gold 6130 2.10GHz 950W No RAM GPU HDD 4x SATA
$374.48

HP Z440 Workstation TWR Xeon E5-1603 v3, 8GB RAM, NVS310, SB1570, NO SSD/OS #95
$89.99

Dell Precision Tower 7810 Xeon E5-2630 v3 @ 2.40GHz , 32GB Ram, NO HDD, NO OS
$239.99