s243a

/usr/bin/cp_user_for_remaster

Aug 4th, 2019
92
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #/bin/bash
  2. TargetBase=/tmp
  3. SourceBase=''
  4. if [ -h "/initrd$SAVE_LAYER" ]; then
  5.   SourceBase="/initrd$SAVE_LAYER"
  6. elif [ -h /initrd/pup_ro1 ]; then
  7.   SourceBase="/initrd/pup_ro1"  
  8. fi
  9.  
  10. for aUser in root; do #remaster script should create a folder of user dirs instead of just root.
  11.                       #In which case we also add the following to the loop: spot puppy fido etc.
  12.   aHOME=$(eval echo "~$aUser")
  13.     if [ ! -z "$SourceBase" ]; then
  14.       cd "$SourceBase"
  15.     else
  16.       cd /
  17.     fi  
  18.     cd ".$aHOME"      
  19.   while read aFile; do
  20.     if [ ! -z "$SourceBase" ]; then
  21.       cd "$SourceBase"
  22.     else
  23.       cd /
  24.     fi
  25.     cd ".$aHOME"  
  26.     do_echo=0 #It doesn't really matter how we intialize this because we cover all cases below
  27.     aDIR="${aFile#./}"
  28.     aDIR="${aDIR%%/*}"
  29.     case "$aDIR" in
  30.     .cache) do_echo=0 ;; #Likely private browser settings in here
  31.     .config)  do_echo=1 ;; #TODO we should probably look at the specific files in this directory  
  32.     #There seems to be some /tmp folder in .jwm that we might want to exclude.
  33.     Choices|.icons|.jwm) do_echo=1 ;; #These folder will probably only change if you change the theme
  34.     Desktop) do_echo=1 ;; # here normally shouldn't be private info here but maybe we need to consider this further.
  35.     Download) do_echo=0 ;; #Exclude this stuff from the iso
  36.     .local) do_echo=0 ;; #Potential meta data in here that we want to exclude (e.g. /recently-used.xbel)
  37.     .mozilla) do_echo=0 ;; #Probably firefox profile info here
  38.     .pbookmarks|pfavorites) do_echo=0 ;; #Probably not much to wory about here but lets not copy since it probably isn't that useful.  
  39.     geany|gtk-3.0|ptheme) do_echo=1 ;;
  40.     rox.sourceforge.net)
  41.       if [ -d /root/rox.sourceforge.net ]; then
  42.         do_echo=1
  43.       else #Because of the way find works this should never actually happen
  44.            #However, this folder might be symlinked to allow users to share rox settings.
  45.         do_echo=0
  46.       fi    
  47.       ;;
  48.     pkg) do_echo=2 ;; #Let's make this directory if it doesn't exist.
  49.     .pkg) do_echo=1 ;;
  50.     .pRecent) do_echo=0 ;; #Possible metadata here that we want to exclude
  51.     .ptheme) do_echo=0 ;; #This seems to be only temporary files used in the theme change. Perhaps we should even delete this stuff if exists on the live cd.
  52.     puppy_reference) do_echo=1 ;; #This stuff might be usefull
  53.     .ssh) do_echo=0 ;; #Exclude this folder since it contains private keys
  54.     .subversion) do_echo=0  ;; #Possibly private keys in here. Further experimentaiton will be required to see if we need anything here.
  55.     #The following are actually files
  56.     .bashrc|.gtkrc-2.0|.jwmrc|.profile|.xinitrc) #These are actually files
  57.       do_echo=1  ;; #Some of these files are auto generated such as .gtkrc-2.0, .jwmrc
  58.     *)
  59.     do_echo=0
  60.   esac
  61.  
  62.   if [ $do_echo -eq 1 ]; then
  63.     if [ "$aFile" -nt "$TargetBase$aHOME/$aFile" ] || \
  64.        [ ! -e "$TargetBase/$aFile" -a ! -h "$TargetBase$aHOME/$aFile" ]; then
  65.        cd "$SourceBase"
  66.        echo ".$aHOME/$aFile" | cpio -pd "$TargetBase"
  67.     fi
  68.   elif [ $do_echo -eq 2 ]; then
  69.     mkdir -p "$TargetBase$aHOME/$aDIR"
  70.   fi
  71.   done < <(find "." -name '*')
  72. done
RAW Paste Data