Current location

narf Source control manager Git

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Daly <Nick.M.Daly@gmail.com>2013-03-19 20:15:41 -0500
committerNick Daly <Nick.M.Daly@gmail.com>2013-03-19 20:15:41 -0500
commit1153e6f45c765e1332da002320ae6c48a3c792ff (patch)
tree9a58a3dc98eb7c9c7fd056294288236e0b9d977f /bin/freedombox-customize
parent55afc0fbfafd3e5b7350d953f0748ed7055360cd (diff)
Moved executable build files from root to bin/
Diffstat (limited to 'bin/freedombox-customize')
-rwxr-xr-xbin/freedombox-customize58
1 files changed, 58 insertions, 0 deletions
diff --git a/bin/freedombox-customize b/bin/freedombox-customize
new file mode 100755
index 0000000..2dd6e91
--- /dev/null
+++ b/bin/freedombox-customize
@@ -0,0 +1,58 @@
+#!/usr/bin/python
+
+import crypt
+import os
+import subprocess
+import sys
+import string
+
+user = "fbx"
+password = "frdm"
+sysuser='plinth'
+syspassword='config'
+rootdir = sys.argv[1]
+home = "/home/{0}/".format(user)
+curr = os.getcwd()
+project_script = "/bin/projects"
+source="{0}/source/".format(curr)
+
+
+def runchroot(argv):
+ return runcmd(["chroot", rootdir] + argv)
+
+def runcmd(argv, stdin='', ignore_fail=False, **kwargs):
+ p = subprocess.Popen(argv, stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ **kwargs)
+ out, err = p.communicate(stdin)
+ if p.returncode != 0:
+ msg = 'command failed: %s\n%s\n%s' % (argv, out, err)
+ if not ignore_fail:
+ print (msg)
+ raise Exception(msg)
+ return out
+
+def make_user(user, password):
+ """Create a user with specified password."""
+
+ runchroot(['adduser', '--gecos', user, '--disabled-password', user])
+ encrypted = crypt.crypt(password, '..')
+ runchroot(['usermod', '-p', encrypted, user])
+
+
+if __name__ == "__main__":
+ print 'Customizing freedombox'
+
+ # Create user accounts
+ make_user(user, password)
+ make_user(sysuser, syspassword)
+
+ # Sync up Source folder
+ # copy!
+ os.system('rsync -av '+source+' '+rootdir)
+
+ # Create all projects
+ os.chdir(rootdir)
+ subprocess.call("{0}{1} {2}".format(curr, project_script,
+ rootdir + home).split())
+ os.chdir(curr)