# refracta.freeforums.org

place to talk about refracta

Skip to content

Welcome
Welcome to refracta You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!

## Using live-config with Refracta

Refracta Development, Scripts, etc.
Post a reply
4 posts • Page 1 of 1

### Using live-config with Refracta

by dzz » Sat Dec 03, 2011 4:59 pm

I have been investigating use of live-config with Refracta. I'm no expert on this stuff, may have got quite a few things wrong but here are some observations.
Live-config scripts do not run by default in Refracta, they don't have to (but can if required by user) because Refracta has preconfigured settings, (a usual Debian Live image does user-setup, hostname, ..... "on-the-fly")
Just to clarify what live-config actually does :
When live-config (or just "config") is added to the cmdline of a live session, all scripts in /lib/live/config are run during bootup, in number order. <man live-config>
It is possible at cmdline to select what scripts are to be enabled or disabled
Some of these scripts are irrelevant to Refracta, e.g. user-setup, because the live user is already configured. They usually include conditions to check for existing configurations and act accordingly, in most cases do nothing. So if they do or don't run, Refracta will be mostly unaffected
Others, e.g. sysvinit, locales, keyboard-configuration definitely do work for Refracta and may be useful.
Of particular interest is live-config.hooks, something I haven't looked at yet in much detail. That allows scripts placed in the live-media's "live" directory to run at bootup. For example, it should allow for a user to just put the current clamav defs in there and a script to install it, for a live-usb setup. You don't have to rebuild the squashfs. Or an essential nonfree firmware. The limitation here seems a user's imagination!
There is also the option of including custom live-config scripts in a snapshot, as documented in /usr/share/doc/live-config. I have done this myself successfully, with a script to set keyboard-layout according to locale.
We recently proved that locale/language and keyboard can be set from the boot prompt in this way, selecting only the relevant live-config scripts to run.
I decided to investigate what would happen in refracta if all scripts were run. It doesn't seem much of a problem with some minor exceptions and doesn't significantly increase boot time.
One exception was the gdm script. It will autologin the Refracta Live user. You may or may not want that. If it runs, on logout you get this at gdm screen:
"User Linux will autologin in : seconds"
(there is no such user, I'm guessing it's looking for the last one to login)
This seems to be set by /usr/lib/gdm/gdmlogin. This is a binary, maybe a config for it was deleted by snapshot.
This seems to have no adverse affect and autologin proceeds for Refracta's "user" (BTW, password for "user" is refracta's setting, not "live" as is debian-live default but for autologin you don't need to enter it)
If "noatologin" is passed at cmdline, the gdm script is not called and the usual Refracta gdm screen appears. That behavior is then no longer an issue.
As the config scripts run, a "state" file for each is made at /var/lib/live/config/
I listed what was in there:
hostname
initramfs-tools
login
openssh-server
policykit
refracta-configs
sysv-rc
tzdata
util-linux
(note refracta-configs, a custom one for my personal snapshot to set keyboard/locale, is there too but not gdm, I had done "noautologin")
Those are all that have run (but may have done nothing, e.g. hostname, because hostname is already set)
Others from /lib/live/config have left no state file because of early exit, e.g. user-setup, because our user is already set up.
I'm still looking at the state file list to see if any might have adverse affect on Refracta, my guess at the moment is no they won't.
Possible hiccup: initramfs-tools might do a dpkg-divert on update-initramfs, to stop that happening in live mode. The installer would need to reverse that (not difficult)
The disadvantage of using selected scripts only, e.g. locales, is more typing at cmdline (=more scope for error) also, syslinux is not very forgiving of editing typos, here the screen goes berserk and fills with text.
Much easier to just put in, for example, locales=de_DE.UTF-8 and nothing else !
No difficulty for a live usb, you edit the syslinux menu once only.
There is some potentially useful stuff to learn. Please post/discuss any comments, corrections, ideas, suggestions, amazing revelations .... on this subject here.

dzz
  Posts: 647
  Joined: Wed Apr 27, 2011 11:53 am
  Location: Devon, England

Top

### Re: Using live-config with Refracta

by dzz » Tue Dec 06, 2011 6:22 pm

Live-config hooks is amazing!
Booting from usb with an (almost) unmodified Refracta, not using persistence,
One simple test script placed on the live-media did all this, during bootup, with zero user interaction:
Set custom runlevels (X starts at 5)
Install .debs from a directory in the live-media
Configure and automatic connect encrypted wireless network
Enable notebook tap-pad

dzz
  Posts: 647
  Joined: Wed Apr 27, 2011 11:53 am
  Location: Devon, England

Top

### Re: Using live-config with Refracta

by fsmithred » Wed Dec 07, 2011 4:31 pm

So it's possible for the user to fill in some variables in a script or config file and add it to the usb stick to customize it? I like it. Can I see the script?

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

Top

### Re: Using live-config with Refracta

by dzz » Thu Dec 08, 2011 7:09 pm

Ok, I'll go into a bit more detail. Firstly, you need to read <man live-config> so you understand what's going on.
What I did discover is, if you enable live-config.hooks (or simply "hooks") *all* the live-config scripts will run, I couldn't get only that to work. That seems no problem as long as "noautologin" is specified but we are still investigating that. (possible installer issue with update-initramfs diversion)
Here is my cmdline:

Code: Select all
  `boot=live showmounts noprompt noautologin initrd=/live/initrd.img union=aufs quiet vga=791 hooks=file:///live/image/script locales=en_GB.UTF-8 5`

The interesting bit is "hooks= file:///live/image/hookscript" ( "file:///" is required). It will run that script, provided it exists in the root of the usb stick althouh it could be point to a subdirectory. I put some debs in the /live directory, they will get installed during bootup.
I'm using "showmounts" so nothing is hidden (although, unless you use a hacked initrd, the live-media partition will be RO) Locale will be set from usual live-config which will run. "noautologin" will stop live-config messing with gdm. The "5" at the end is because i am going to tweak default runlevels, if I do 2 or 3 it's console only, can be very useful.
Here's the script. It could be anything, this is only what I used. I got the wlan configs from a previous Refracta live session. (the "secure" bits are edited, this is a public forum)

Code: Select all
  `#!/bin/bash
  if [ -d /live/findiso ]; then
  # (only if) we use a grml-type custom initrd with "findiso" parameter
  LIVEMEDIAMOUNTPOINT="/live/findiso"
  else
  # usual Debian-Live is :
  LIVEMEDIAMOUNTPOINT=/live/image
  fi
  # make a Desktop text file so it is seen to work
  echo "Hello, live-hook! Testing." >/home/user/Desktop/hellohook
  # change default runlevel to 5 to make life easier to switch in/out of X
  sed -i "s/id:[1-5]:initdefault:/id:5:initdefault:/" /etc/inittab /usr/share/sysvinit/inittab
  sysv-rc-conf --level 012346 gdm off
  sysv-rc-conf --level 5 gdm on
  # put wlan settings in the right place (is set to autoconnect)
  cat >/etc/wicd/wireless-settings.conf << EOF
  [code_for _access_point]
  afterscript = None
  dhcphostname = refracta
  bssid = my_bssid
  postdisconnectscript = None
  use_dhcphostname = 0
  dns_domain = None
  quality = 54
  gateway = None
  use_global_dns = 0
  strength = -72
  encryption = True
  bitrates = 24 Mb/s
  ip = None
  beforescript = None
  hidden = False
  channel = 11
  mode = Master
  has_profile = False
  netmask = None
  key = my_network_key
  predisconnectscript = None
  enctype = wpa
  dns3 = None
  dns2 = None
  dns1 = None
  use_settings_globally = 0
  use_static_dns = 0
  encryption_method = WPA
  essid = my_essid
  search_domain = None
  automatic = True
  EOF
  #########################################
  # install some debs from our live media device:
  for i in $( ls $LIVEMEDIAMOUNTPOINT/live|grep .deb ); do
  dpkg -i $LIVEMEDIAMOUNTPOINT/live/$i ;
  done
  ########## make a script to enable laptop touchpad
  if [ -d /home/user/.config/autostart ]; then
  # create this script
  cat > /home/user/.config/autostart/synaptics.sh <<EOF
  #!/bin/bash
  # user script to enable touchpad
  synclient TapButton1=1 LBCornerButton=2 RBCornerButton=3 MaxTapTime=140 SingleTapTimeout=140 MaxDoubleTapTime=140
  EOF
  chmod 755 /home/user/.config/autostart/synaptics.sh
  # Make a .desktop file (so xfce will autostart the script):
  cat > /home/user/.config/autostart/synaptics.desktop <<EOF
  [Desktop Entry]
  Encoding=UTF-8
  Version=0.9.4
  Type=Application
  Name=synaptics
  Comment=
  Exec=/home/user/.config/autostart/synaptics.sh
  StartupNotify=false
  Terminal=false
  Hidden=false
  EOF
  # user must own what root just wrote
  chown -R user:user /home/user/.config/autostart /home/user/.config/autostart/synaptics
  fi
  # add more commands here, your imagination is (mostly) the limit ! Can probably chainload other scripts too
  `

EDIT The installer does check for update-initramfs diversion

dzz
  Posts: 647
  Joined: Wed Apr 27, 2011 11:53 am
  Location: Devon, England

Top

Display posts from previous:
Sort by

Post a reply
4 posts • Page 1 of 1

Return to Discuss

Jump to:

### Who is online

Users browsing this forum: No registered users and 0 guests

Donate Now
ProNight Style by ModphpBB3
Hosted by © 2017 FreeForums.org | Create a free forum | Powered by phpBB
A Member of the Crowdgather Forum Community
About FreeForums | Legal | Advertise Here | Investors | Contact FreeForums.org
Report Violation
suspicion-preferred