Skip to content

Commit

Permalink
Merge pull request #99 from herpiko/bift2
Browse files Browse the repository at this point in the history
Fix bift support
  • Loading branch information
herpiko authored Aug 16, 2016
2 parents 2c7f79c + c550ac6 commit 788dde9
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 7 deletions.
5 changes: 5 additions & 0 deletions scripts/b-i-post
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ echo "BEGIN OF POST INSTALLATION LOG" >> /var/log/blankon-installer.log
echo "fdisk -l" >> /var/log/blankon-installer.log
/sbin/fdisk -l >> /var/log/blankon-installer.log
echo "END OF POST INSTALLATION LOG" >> /var/log/blankon-installer.log

BIFTADDR="10.0.2.2"
curl -T /var/log/blankon-installer.log ftp://$BIFTADDR:2121/
curl -T /var/log/blankon-installer.parted.log ftp://$BIFTADDR:2121/

2 changes: 1 addition & 1 deletion scripts/b-i-setup-fs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ do_chroot /usr/bin/apt-get --yes clean

read AUTOLOGIN USERNAME < $ROOTFS/tmp/user-setup
echo "Configuring user $USERNAME"
echo "Auto-login: $AUTOLIGIN"
rm -f $ROOTFS/tmp/user-setup


# This is the original group used in full ISO of BlankOn, since the current ISO generate the minimum packages,
# some groups doesnt exist.
# USER_GROUPS=sudo,cdrom,floppy,audio,dip,video,plugdev,scanner,netdev,bluetooth
Expand Down
16 changes: 16 additions & 0 deletions scripts/blankon-session-try-installer
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ if [ $? -eq 0 -a -x /usr/bin/blankon-installer ];then
rm -f /run/locale
chown -R 1000:1000 /run/user/1000/dconf

# Check for BIFT instance
BIFTADDR="10.0.2.2"
nc -z $BIFTADDR 2121
BIFT=`echo $?`
if [ "x$BIFT" = "x0" ];then
curl ftp://$BIFTADDR:2121/scenario > /tmp/scenario
if [ "x$?" = "x0" ];then
SCENARIO=`cat /tmp/scenario`
export DEBUG=1
export AUTOFILL=1
export SCENARIO=$SCENARIO
sudo -E bash -c 'echo $DEBUG'
sudo -E bash -c 'echo $AUTOFILL'
sudo -E bash -c 'echo $SCENARIO'
fi
fi
sudo -E nice -n -20 blankon-installer

# Run post-install script when created by blankon-installer
Expand Down
25 changes: 23 additions & 2 deletions src/installer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ public class Installation : GLib.Object {
switch (entry [0]) {
case "device":
device = int.parse (entry[1]);
Log.instance().log ("Selected Drive : " + device.to_string ());
Log.instance().log ("Device : " + device.to_string ());
break;
case "device_path":
device_path = entry[1];
Log.instance().log ("Device path : " + device_path.to_string ());
break;
case "partition":
partition = int.parse (entry[1]);
Log.instance().log ("Partition : " + partition.to_string ());
break;
case "username":
user_name = entry[1];
Expand Down Expand Up @@ -285,6 +287,8 @@ public class Installation : GLib.Object {
break;
case Step.DONE:
if (state != State.ERROR) {
string command = "/sbin/b-i-post";
Process.spawn_command_line_sync(command);
Log.instance().log ("ERROR");
description = "Done";
} else {
Expand Down Expand Up @@ -624,22 +628,27 @@ public class Installation : GLib.Object {

void do_setup () {
var content = ("%s:%s\n").printf(user_name, password);
Log.instance().log("/tmp/user-pass : " + content);
Utils.write_simple_file ("/tmp/user-pass", content);
if (rootPassword.length > 0) {
if (secureInstall && rootPassword.length > 0) {
content = ("root:%s").printf(rootPassword);
Utils.write_simple_file ("/tmp/root-pass", content);
}

content = ("%d %s\n").printf((int) autologin, user_name);
Log.instance().log("/tmp/user-setup : " + content);
Utils.write_simple_file ("/tmp/user-setup", content);

content = ("%s\n\n\n\n\n").printf(full_name);
Log.instance().log("/tmp/user-info : " + content);
Utils.write_simple_file ("/tmp/user-info", content);

content = ("%s\n").printf(host_name);
Log.instance().log("/tmp/host_name : " + content);
Utils.write_simple_file ("/tmp/hostname", content);

content = ("%s\n").printf(timezone);
Log.instance().log("/tmp/timezone : " + content);
Utils.write_simple_file ("/tmp/timezone", content);

SwapCollector.reset ();
Expand Down Expand Up @@ -1106,6 +1115,17 @@ public class Installation : GLib.Object {
}
return new JSCore.Value.string(ctx, new JSCore.String.with_utf8_c_string(retval));
}

public static JSCore.Value js_scenario (Context ctx,
JSCore.Object function,
JSCore.Object thisObject,
JSCore.Value[] arguments,
out JSCore.Value exception) {

string retval = "false";
string scenario = GLib.Environment.get_variable("SCENARIO");
return new JSCore.Value.string(ctx, new JSCore.String.with_utf8_c_string(scenario));
}

static const JSCore.StaticFunction[] js_funcs = {
{ "shutdown", js_shutdown, PropertyAttribute.ReadOnly },
Expand All @@ -1122,6 +1142,7 @@ public class Installation : GLib.Object {
{ "getCopyingProgress", js_get_copying_progress, PropertyAttribute.ReadOnly },
{ "debug", js_debug, PropertyAttribute.ReadOnly },
{ "autofill", js_autofill, PropertyAttribute.ReadOnly },
{ "getScenario", js_scenario, PropertyAttribute.ReadOnly },
{ null, null, 0 }
};

Expand Down
5 changes: 4 additions & 1 deletion src/parted.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ public class PartedLog : GLib.Object {

public PartedLog () {
try {
var file = File.new_for_path ("/var/log/blankon-installer.log");
var file = File.new_for_path ("/var/log/blankon-installer.parted.log");
if (file.query_exists ()) {
file.delete ();
}
stream = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION));
} catch (Error e) {
stderr.printf ("%s\n", e.message);
Expand Down
24 changes: 21 additions & 3 deletions system/src.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ angular.module("hello",[])
$rootScope.isBiosBootExists = Installation.isBiosBootExists()=='true' ? true : false;
$rootScope.debug = Installation.debug()=='true' ? true : false;
$rootScope.autofill = Installation.autofill()=='true' ? true : false;
$rootScope.scenario = Installation.getScenario();
}

if ($rootScope.autofill) {
Expand Down Expand Up @@ -270,8 +271,6 @@ angular.module("partition",[])
if ($rootScope.selectedInstallationTarget || $scope.cleanInstall) {
$rootScope.cleanInstall = $scope.cleanInstall;
$rootScope.next();
} else {
console.log('bah');
}
}

Expand Down Expand Up @@ -1016,9 +1015,9 @@ angular.module("partition",[])
}
$scope.setDrive = function(drive) {
// TODO : reset UI
$rootScope.installationData.device = $rootScope.devices.indexOf(drive);
var path = drive.path;
$rootScope.currentPartitionTable = drive.label;
$rootScope.installationData.device = $rootScope.devices.indexOf(drive);
$rootScope.installationData.device_path = path;
// If it's not a GPT and booted up on UEFI system, do the clean install
$scope.cleanInstall = ($rootScope.currentPartitionTable !== 'gpt' && $rootScope.isEfi);
Expand Down Expand Up @@ -1083,7 +1082,26 @@ angular.module("partition",[])
}
}
}

// BIFT

if ($rootScope.scenario && $rootScope.scenario.length > 0) {
var scenario = JSON.parse($rootScope.scenario);
console.log('Scenario');
console.log(scenario);
var keys = Object.keys(scenario.data);
for (var i in keys) {
$rootScope.installationData[keys[i]] = scenario.data[keys[i]];
console.log($rootScope.installationData[keys[i]]);
// Some values are not included in installationData object, catch it
if (keys[i] === 'cleanInstall' || keys[i] === 'partitionSteps' || keys[i] === 'advancedPartition') {
$rootScope[keys[i]] = scenario.data[keys[i]]
}
}
$rootScope.next();
}
}

])

angular.module("summary",[])
Expand Down

0 comments on commit 788dde9

Please sign in to comment.