Refracta Development, Scripts, etc.
Post a reply
raymerjacque

- raymerjacque
- Posts: 111
- Joined: Sun Nov 03, 2013 9:37 am

## Skel Copy feature.

Wed Mar 08, 2017 6:17 pm

@fsmithred
Could you add an automated copy home to skel section into your script ? I don't know if you use this feature for your distro's but most guys will. it makes a backup of config files from the user/home directory to the /etc/skel/ folder to create a template for when you create new users on the system. in a nutshell if you create a new user it will create a home directory from the template in skel folder, thus pull the settings the old user backed up. here is a script i modified from remastersys seperately to do this :

Code:
  `#!/bin/bash
  #Backup Utility
  echo "Welcome to Backup-Tool"
  sleep 2
  echo "We will First Backup the home/user/ directory to /etc/skel"
  echo "Once this Backup is completed, You can run snapshot to create the ISO."
  sleep 2
  echo "We begin in 8 seconds..."
  sleep 8
  testroot="`whoami`"
  if [ "$testroot" != "root" ]; then
  echo "Must be root"
  exit 1
  fi
  SKELUSER="$1"
  if [ "$SKELUSER" = "" ]; then
  echo "Usage is: skelcopy username"
  echo "Where username is a valid user on the system"
  exit 1
  fi
  SKELFOLDER=`grep "^$SKELUSER:" /etc/passwd | awk -F ":" '{print $6}'`
  if [ -d "$SKELFOLDER" ]; then
  cd $SKELFOLDER
  echo "Commence with Backup process"
  sleep 2
  echo "Get rid of old files and folders in /etc/skel"
  sleep 2
  rm -rf /etc/skel/.cinnamon
  rm -rf /etc/skel/.config
  rm -rf /etc/skel/.gconf
  rm -rf /etc/skel/.gnupg
  rm -rf /etc/skel/.icons
  rm -rf /etc/skel/.kde*
  rm -rf /etc/skel/.linuxmint
  rm -rf /etc/skel/.local
  rm -rf /etc/skel/.pki
  rm -rf /etc/skel/.ssh
  rm -rf /etc/skel/.tickr
  rm -rf /etc/skel/.bash_history
  rm -rf /etc/skel/.bash_logout
  rm -rf /etc/skel/.dmrc
  rm -rf /etc/skel/.bacon
  rm -rf /etc/skel/.xscreensaver
  rm -rf /etc/skel/.bashrc
  rm -rf /etc/skel/.profile
  rm -rf /etc/skel/.gconf
  rm -rf /etc/skel/.gnome2
  rm -rf /etc/skel/.gnome
  rm -rf /etc/skel/.chrome
  rm -rf /etc/skel/.chromium
  rm -rf /etc/skel/.google-chromium
  rm -rf /etc/skel/.mozilla
  rm -rf /etc/skel/.icons
  rm -rf /etc/skel/.themes
  rm -rf /etc/skel/.xfce
  rm -rf /etc/skel/.xfce4
  rm -rf /etc/skel/.local
  rm -rf /etc/skel/.icewm*
  rm -rf /etc/skel/.fvwm*
  rm -rf /etc/skel/.afterstep*
  rm -rf /etc/skel/.gtkrc*
  rm -rf /etc/skel/.mate*
  rm -rf /etc/skel/.pekwm*
  rm -rf /etc/skel/.qt*
  rm -rf /etc/skel/.kde*
  rm -rf /etc/skel/.razor
  rm -rf /etc/skel/.wbar
  rm -rf /etc/skel/.mplayer
  rm -rf /etc/skel/.wine
  rm -rf /etc/skel/.xfce
  rm -rf /etc/skel/.xfce4
  rm -rf /etc/skel/.kde
  rm -rf /etc/skel/.gnome
  rm -rf /etc/skel/.gnome2
  echo "Finished Deleting files from /etc/skel"
  sleep 2
  echo "We will now copy over new files to /etc/skel"
  sleep 5
  echo "Copying current user profile and config files to /etc/skel"
  sleep 5
  sed -i -e "s/$SKELUSER//g" /etc/skel/.xscreensaver
  rsync -a .cinnamon /etc/skel/
  rsync -a .config /etc/skel/
  rsync -a .xfce /etc/skel/
  rsync -a .xfce4 /etc/skel/
  rsync -a .kde /etc/skel/
  rsync -a .gnome /etc/skel/
  rsync -a .gnome2 /etc/skel/
  rsync -a .gconf /etc/skel/
  rsync -a .gnupg /etc/skel/
  rsync -a .icons /etc/skel/
  rsync -a .linuxmint /etc/skel/
  rsync -a .local /etc/skel/
  rsync -a .pki /etc/skel/
  rsync -a .ssh /etc/skel/
  rsync -a .themes /etc/skel/
  rsync -a .tickr /etc/skel/
  rsync -a .bashrc /etc/skel/
  rsync -a .bash_history /etc/skel/
  rsync -a .bash_logout /etc/skel/
  rsync -a .dmrc /etc/skel/
  rsync -a .profile /etc/skel/
  rsync -a .face /etc/skel/
  rsync -a .mozilla /etc/skel/
  rsync -a .chromium /etc/skel/
  rsync -a .google-chrome /etc/skel/
  rsync -a .google-chromium /etc/skel/
  clear
  echo "Ignore any missing file errors"
  echo "We delete some useless left over files from /etc/skel"
  sleep 5
  rm -rf /etc/skel/.wine
  rm -rf /etc/skel/.dbus
  rm -rf /etc/skel/.config/user-dirs.locale
  echo "Setting up Permissions on /etc/skel"
  sleep 5
  chown -R root:root /etc/skel
  sleep 2
  echo "All Finished, User configuration Back up complete."
  else
  echo "$1 either not found or doesn't have a proper home folder - exiting."
  exit 1
  fi
  `

save the filename as "skelcopy" in /usr/bin/
the default command used to run the script : sudo skelcopy user
the command I use to run the script : sudo skelcopy ${USER:=$(/usr/bin/id -run)}
( this just lets the script automatically use the currently logged in user )
Maybe you could add it into yours as a side script that can be enabled in your refractsnapshot config file, it would automate the backup to skel process, it should run before the actual snapshot starts. it is a simple script, but Very effective
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: Skel Copy feature.

Wed Mar 08, 2017 11:57 pm

I did put some user configs in /etc/skel in the refracta8.2 isos, but I removed them in 8.3. Instead, there are some config files in /etc/xdg. That may change again when the new devuan desktop-base package is finished, which should make custom theming easier for downstream distros.
I see some potential problems with the stuff that's getting copied in your script. The user's .ssh and .gnupg dirs should generally not be shared with other users. The browser caches and bash_history also may contain things you don't want to share. And some of the configfiles may contain "/home/username" that won't match with the new user.
If someone wants to put extra config files in /etc/skel, those files will get copied into the snapshot. Why would you want to update them right before making a snapshot? I would think it best to put them in /etc/skel before there's any cache or history in there. Anyway, I'm not saying yes or no. I'll look at this again later. Thanks.
thwak

- thwak
- Posts: 174
- Joined: Tue Nov 20, 2012 3:58 am

## Re: Skel Copy feature.

Fri Mar 10, 2017 10:00 pm

Preconfigured templates for browser profile require special handling.
As fsmithred mentioned, due to user-specific hardcoded paths (within preferences file, addon config files, sqlite3 database files) you will introduce breakage by attempting to just copy .mozilla to and from set/skel
I don't know chrome. For firefox, there's a CCK2 utility dedicated to the task of creating a custom, pre-configured profile.
https://mike.kaply.com/cck2/

Code:
  `rm -rf /etc/skel/.linuxmint
  . . .
  rm -rf /etc/skel/.tickr`

How did each of these items come into existence?
Unless I could be certain of the answer for each prospective removal candidate, I would hesitate to remove it. Seems like you're attempting to reduce clutter. I'm all for that, but if any of those files were placed during debootstrap... who can guess what will happen (break) when programs are unable to find a particular DEFAULT config, missing because I (you) chose to axe (for instance) rm -rf etc/skel/.pki
To establish "system-wide defaults", files residing in several paths other than etc/skel must be customized. For instance the default "rules" file, for UFW, IIRC is not pathed under etc/skel. To find the various places customized default config files may need to be placed, it will be enlightening for you to highlight a given program (package) within synaptic, then refer to the ("Details" pane) "installed files" listing for the package.
Post a reply
Jump to:

Powered by phpBB © phpBB Group.

phpBB Mobile / SEO by Artodia.