s243a

/usr/bin/cp_etc_for_remaster

Aug 4th, 2019
114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #/bin/bash
  2. TargetBase=/tmp
  3. SourceBase=''
  4. keepDefaults(){
  5.     if [ $# -gt 0 ] ; then
  6.       TargetPath="$TargetBase/etc/$1"
  7.     else
  8.       TargetPath="$TargetBase/etc/$aFile"
  9.     fi
  10.       if [ ! -e "$TargetPath" ]; then #TODO: Maybe just check the base sfs for the folder
  11.         do_echo=1
  12.       else
  13.         do_echo=0
  14.       fi   
  15. }
  16. if [ -h "/initrd$SAVE_LAYER" ]; then
  17.   SourceBase="/initrd$SAVE_LAYER"
  18. elif [ -h /initrd/pup_ro1 ]; then
  19.   SourceBase="/initrd/pup_ro1"  
  20. fi
  21.  
  22.  
  23.  
  24.     if [ ! -z "$SourceBase" ]; then
  25.       cd "$SourceBase"
  26.     else
  27.       cd /
  28.     fi  
  29.     cd "etc"      
  30.   while read aFile; do
  31.     if [ ! -z "$SourceBase" ]; then
  32.       cd "$SourceBase"
  33.     else
  34.       cd /
  35.     fi
  36.     cd etc
  37.     do_echo=0 #It doesn't really matter how we intialize this because we cover all cases below
  38.     aDIR="${aFile#./}"
  39.     aDIR="${aDIR%%/*}"
  40.     case "$aDIR" in
  41.     alternatives|apache2|apm|bash_completion.d|ca-certificates) do_echo=1 ;;
  42.     calendar) do_echo=1 ;; #This might be user specific but keep it for now
  43.     cron.daily) do_echo=1 ;; #Maybe any private related stuff to a cron script can be kept in another folder  
  44.     cron.weekly) do_echo=1 ;; #Maybe any private related stuff to a cron script can be kept in another folder
  45.     dbus-1) do_echo=1 ;; #Some wpa_supplicant settings here but nothing that looks private
  46.     default) do_echo=0 ;; #These settings apear hardware specific
  47.     firefox-esr) do_echo=1 ;;  #This folder overwrides settings in about:config
  48.     fonts)  do_echo=1 ;;  
  49.     frisbee) #wpa_supplicant.conf needs to be excluded for sure, for the rest maybe keep the defaults.
  50.       keepDefaults "$aFile"
  51.       #TargetPath="$TargetBase"/etc/$aFile
  52.       #if [ ! -e "$TargetPath" ]; then
  53.       #  do_echo=1 ;;
  54.       #fi
  55.       if [ "$(basename "$aFile")" = wpa_supplicant.conf ]; then
  56.         do_echo=0
  57.       fi
  58.       ;;
  59.     grof|gss|gtk-2.0|gtk-3.0) do_echo=1 ;;
  60.     ifplugd) do_echo=1 ;; #Any private info needed for these scripts could be put in another folder
  61.     init.d|jwm|ldap|ld.so.conf.d|libnl-3|logrotate.d|mc|menu-methods) do_echo=1 ;;
  62.     modprobe.d) do_echo=0 ;; #There might be some hardware specific stuff here
  63.     modules) do_echo=0 ;; #There might be some hardware specific stuff here
  64.     network) do_echo=1 ;; #this stuff looks okay but research this more  
  65.     network-wizard) #This folder might contain some private network stuff so keep default values for now.
  66.        do_echo=0 ;;
  67.     newt|pam.d) do_echo=1 ;;
  68.     pcmcia) do_echo=0 ;; #There might be some hardware specific stuff here
  69.     perl|pkg|pm) do_echo=1 ;;
  70.     ppp) do_echo=0 ;; #There might be some private network settings in here
  71.     profile.d) do_echo=1 ;; #Assume that people won't put private stuff here
  72.     rc.d) do_echo=1 ;; #not sure that PUPSTATE needs to be in the iso but it doesn't hurt anything
  73.     selinux|sensors.d) do_echo=1 ;;
  74.     simple_network_setup) #This folder might contain some private network stuff so keep default values for now.
  75.        do_echo=0 ;;
  76.     skel) do_echo=1 ;;
  77.     ssh|ssl) do_echo=1 ;; #The keys are normally placed in the root folder so we should be okay here.
  78.     subversion) keepDefaults "$aFile" ;;
  79.     sysconfig) do_echo=0 ;; #There might be some hardware specific stuff here
  80.     sysctl.d) do_echo=1 ;; #I need to research this more
  81.     udev) do_echo=1 ;; #Rebuild initrd if this folder ismodified. See comments in /etc/udev/udev.conf
  82.     wbar.d) do_echo=1 ;;
  83.     wpa_supplicant) do_echo=1 ;; #Looks okay but verify before running script that no private network info is in folder.
  84.     X11) do_echo=0 ;; #This folder might contain custom settings so keep defaults for now.
  85.     xdg) do_echo=1 ;;
  86.     #-------------------Now Let's look at files
  87.     profile|windowmanager)  do_echo=1 ;;
  88.     *)
  89.     do_echo=0 ;;
  90.   esac
  91.  
  92.   if [ $do_echo -eq 1 ]; then
  93.     if [ "$aFile" -nt "$TargetBase/$aFile" ] || \
  94.        [ ! -e "$TargetBase/etc/$aFile" -a ! -h "$TargetBase/etc/$aFile" ]; then
  95.        cd "$SourceBase"
  96.        echo "./etc/$aFile" | cpio -pd "$TargetBase"
  97.     fi
  98.   elif [ $do_echo -eq 2 ]; then
  99.     mkdir -p "$TargetBase/etc/$aDIR"
  100.   fi
  101.   done < <(find "." -name '*')
RAW Paste Data