]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
Merged patch by Tomasz Witek <tiwek@manta.univ.gda.pl>:
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Sat, 4 Oct 2003 09:46:51 +0000 (09:46 +0000)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Sat, 4 Oct 2003 09:46:51 +0000 (09:46 +0000)
- ignore Latency in /proc/pci
- ability to choose profile while booting
- example profile file
- misc fixes and cleanups

svn-id: @1404

hwprofile
sysconfig/hwprof
sysconfig/hwprofiles/Makefile.am
sysconfig/hwprofiles/files [new file with mode: 0644]

index df513b344ccec370f2f0cf297612a5fbb0e4a351..50baf2eafc23aa8e081f8d9eafaa03494859a88f 100755 (executable)
--- a/hwprofile
+++ b/hwprofile
@@ -6,7 +6,10 @@
 PROFDIR="/etc/sysconfig/hwprofiles"
 QUIET=0
 
-[ -z "${EDITOR} " ] && EDITOR=vi
+. /etc/rc.d/init.d/functions
+. /etc/sysconfig/hwprof
+
+[ -z "${EDITOR}" ] && EDITOR=vi
 
 if [ "$(id -u)" != "0" ]; then
        echo "Need superuser privileges. Can't continue!"
@@ -20,7 +23,7 @@ fi
 
 myecho()
 {
-  if [ "${QUIET}" != "1" ]; then
+  if [ $QUIET -eq 0 ]; then
     echo $@
   fi
 }
@@ -47,7 +50,7 @@ md5sumgen()
 {
   ( \
   grep -v "MHz" /proc/cpuinfo 2> /dev/null \
-  cat /proc/pci 2> /dev/null \
+  grep -v "Latency" /proc/pci 2> /dev/null \
   ) | md5sum | awk ' { gsub(/ .*$/,NIL); print $0 } '
 }
 
@@ -78,9 +81,12 @@ while getopts adflsqr: opt "$@"; do
        [ -z "${DESCRIPTION}" ] && DESCRIPTION="${PROFILE}"
        echo "${DESCRIPTION}" > ${PROFDIR}/${PROFILE}.desc
        echo "Now, editor will be started and you need to enter list of files"
-       echo "for this profile (later as ${PROFDIR}/${PROFILE}.files)."
+       echo "for this profile (later as ${EDITOR} ${PROFDIR}/${PROFILE}.files)."
        echo "Press Enter."
        read
+       if [ -f ${PROFDIR}/files -o ! -f ${PROFDIR}/${PROFILE}.files ]; then
+         cat ${PROFDIR}/files > ${PROFDIR}/${PROFILE}.files;
+       fi
        ${EDITOR} ${PROFDIR}/${PROFILE}.files
        FILES=
        echo "Validating and copying valid files for this profile:"
@@ -131,15 +137,19 @@ while getopts adflsqr: opt "$@"; do
          echo "Can't setup ${PROFILE}. No required data."
          exit 1
        fi
-       echo "Setting up profile \"${PROFILE}\"..."
+       echo -n "Setting up profile \"${PROFILE}\" "
+       myecho "";
        for file in $(grep -v "^#" ${PROFDIR}/${PROFILE}.files); do
          if [ ! -f ${file} -o "${file}" = "/etc/sysconfig/hwprof" ]; then
-           echo "${file}: invalid, skipping"
+           myecho "${file}: invalid, skipping"
            continue
          fi
-         echo "Copying ${PROFDIR}/data/${PROFILE}/${file} to ${file}..."
-         cp -dp ${PROFDIR}/data/${PROFILE}/${file} ${file}
+         echo -n ".";
+         myecho "Copying ${PROFDIR}/data/${PROFILE}/${file} to ${file}..."
+         cp -dp ${PROFDIR}/data/${PROFILE}/${file} ${file} 2>/dev/null
        done
+       echo ${PROFILE} > /var/run/hwprofile
+       echo " Done.";
        myecho "Profile \"${PROFILE}\" running."
        break
        ;;
@@ -150,6 +160,7 @@ while getopts adflsqr: opt "$@"; do
        for prof in $(ls -1 ${PROFDIR}/*.md5 2> /dev/null); do
          prof=$(basename ${prof})
          CURRENTMD5="$(cat ${PROFDIR}/${prof} 2> /dev/null)"
+               # echo "$prof ${CURRENTMD5} ${PROFILEMD5}";
          [ -z "${CURRENTMD5}" ] && continue
          if [ "${CURRENTMD5}" = "${PROFILEMD5}" ]; then
            PROFILE=$(echo ${prof} | awk ' { gsub(/\.md5/,NIL); print $0 } ')
@@ -157,16 +168,47 @@ while getopts adflsqr: opt "$@"; do
          fi
        done
        if [ -z "${PROFILE}" ]; then
-           if [ ! -f ${PROFDIR}/default.md5 ]; then
+         if is_yes "${ASKFORPROFILE}"; then
+           echo "Avialable profiles:";
+           PS3='Enter number profile: ';
+           LISTA=$(ls ${PROFDIR}/*.desc 2> /dev/null);
+           for i in ${LISTA};
+             do
+               a=$(basename $i .desc);
+               LISTA1="${a} ${LISTA1}";
+             done
+           LISTA1="${LISTA1} Default";
+       
+           select PROFILE in $LISTA1;
+           do
+               if [ "${PROFILE}" ];
+               then
+                       break
+               fi
+           done
+           if [ "${PROFILE}" == "Default" ]; then
+             PROFILE=
+           fi
+         fi
+        fi
+        if [ -z "${PROFILE}" ]; then
+         if [ ! -f ${PROFDIR}/default.md5 ]; then
                echo "Valid profile not found. Starting with current files."
                exit 0
            else
                echo "Valid profile not found. Starting with \"default\" profile."
                PROFILE=default
-           fi
+         fi
+       fi
+
+       if [ ! -z "${PROFILE}" ]; then
+               myecho "Found profile \"${PROFILE}\" with md5sum \"${PROFILEMD5}\"."
+               if [ $QUIET -eq 0 ]; then
+                       $0 -r ${PROFILE};
+               else
+                       $0 -qr ${PROFILE};
+               fi
        fi
-       myecho "Found profile \"${PROFILE}\" with md5sum \"${PROFILEMD5}\"."
-       $0 -r ${PROFILE}
        break
        ;;
     s)
@@ -179,16 +221,19 @@ while getopts adflsqr: opt "$@"; do
          echo "${PROFILE}.files is missing. Can't continue."
          exit 1
        fi
-       echo "Saving/updating current profile..."
+       echo  -n "Saving/updating current [${PROFILE}] profile "
+       md5sumgen > ${PROFDIR}/${PROFILE}.md5
+       myecho "";
        for file in $(grep -v "^#" ${PROFDIR}/${PROFILE}.files); do
+         echo -n ".";
          if [ ! -f ${file} -o "${file}" = "/etc/sysconfig/hwprof" ]; then
-           echo "${file}: invalid, skipping"
+           myecho "${file}: invalid, skipping"
            continue
          fi
-         echo "Copying ${file} to ${PROFDIR}/data/${PROFILE}/${file}"
-         cp -dp --parents ${file} ${PROFDIR}/data/${PROFILE}/
+         myecho "Copying ${file} to ${PROFDIR}/data/${PROFILE}/${file}"
+         cp -dp --parents ${file} ${PROFDIR}/data/${PROFILE}/ 
        done
-       echo "Done."
+       echo " Done."
        break
        ;;
     l)
@@ -227,7 +272,7 @@ while getopts adflsqr: opt "$@"; do
        break
        ;;
     q)
-       QUIET=1
+       QUIET=1; export QUIET;
        ;;
     *)
        showhelp
@@ -245,4 +290,4 @@ fi
 exit 0
 
 # This must be last line !
-# vi:syntax=sh:tw=78:ts=8:sw=2
+# vi:syntax=sh:tw=78:ts=2:sw=2
index 46725676b9769bc8ef4f05159d54f5e1890609e0..80ebedb58c9a9daa12842b2e74e7cbbe6c1acbec 100644 (file)
@@ -3,3 +3,5 @@
 # Enable HWPROFILES support?
 HWPROFILES=no
 
+# Ask for profile if not found
+ASKFORPROFILE=no
index e6ba4d43703980dff1b0dccf0414b191650cf16c..e52e08ce1b9f1a24ccc8c4cbc8bae750c7e80cdf 100644 (file)
@@ -1,3 +1,8 @@
 @SET_MAKE@
 
-#EXTRA_DIST = data
+hwprofilesdir = @sysconfigdir@/hwprofiles
+
+hwprofiles_DATA = \
+                 files
+                         
+EXTRA_DIST = $(hwprofiles_DATA)
diff --git a/sysconfig/hwprofiles/files b/sysconfig/hwprofiles/files
new file mode 100644 (file)
index 0000000..7b29400
--- /dev/null
@@ -0,0 +1,14 @@
+/etc/cups/ppd/*
+/etc/cups/printers.conf
+/etc/sysconfig/interfaces/ifcfg-eth0
+/etc/X11/XF86Config
+/etc/sysconfig/system
+/etc/sysconfig/network
+/etc/sysconfig/mouse
+/etc/hosts
+/etc/resolv.conf
+/etc/modules.conf
+/etc/modules
+/etc/printcap
+/etc/fstab
+/etc/sysconfig/fbset
This page took 0.093095 seconds and 4 git commands to generate.