TurnKey Linux Virtual Appliance Library

di-live for first time config setup

Ok I seem to have TKLPatch working. Now instead of using overlay with fixed config settings I would like to use di-live.

There seem to be two things I need to get sorted.

1 - di-live file

2 - system config applier file

DI-LIVE FILE

Drop this in /usr/lib/di-live.d
WHAT shuld I call the file? The TurnKey ISO file in this location seem to be pre-appended with numbers?       


#!/usr/bin/python
import sys
import common	

TARGET = "/target"

def main():
    if not common.target_mounted(TARGET):
        sys.exit(10) # return to menu

    db = common.Debconf()
    username = db.get_input('Enter value for Username', 'testuser')
    domain = db.get_input('Enter value for Domain', 'corp-domain')
    proxy = db.get_input('Enter value for Proxy', '10.1.1.1:8080')
    password = db.get_password('Enter password')
    chroot = common.Chroot(TARGET)
    chroot.system('cntlm-config %s %s %s %s' % (username, domain, proxy, password ))

if __name__ == "__main__":
    main()

 

SYSTEM CONFIG APPLIER FILE

place in .../overlay/usr/local/bin/cntlm-config


#!/bin/bash 
APT_CONF_FILE="/etc/cntlm.conf"
sed -e '/^Username/s/testuser/$1/g' $APT_CONF_FILE 
sed -e '/^Domain/s/corp-uk/$2/g' $APT_CONF_FILE 
sed -e '/^Password/s/password/$3/g' $APT_CONF_FILE 
sed -e '/^Proxy/s/10\.217\.112\.4.\:8080/$4/g' $APT_CONF_FILE 
sed -e '/^Listen/s/3128/9090/g' $APT_CONF_FILE

The above is untested, I will get to that shortly.

 

So is the approach OK?

What do I call the di-live.d file?

Liraz Siri's picture

A little experimentation goes a long way

Congratulations, it looks like you know what you're doing. For the things you are unsure about, a little experimentation should help to fill in the gaps quickly. That's pretty much what we do when we're trying to get things to work. Test, revise, test again, rinse repeat.

The filename for the di-live.d is basically arbitrary. Choose whatever you like. The numbers determine the execution order but if you don't care about that you can just leave that to chance.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)