Skip to content

Instantly share code, notes, and snippets.

@Immortal-
Created April 19, 2016 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Immortal-/39c79320f396755454bb8a425575d8b0 to your computer and use it in GitHub Desktop.
Save Immortal-/39c79320f396755454bb8a425575d8b0 to your computer and use it in GitHub Desktop.
installer
<?php
function cmd($command)
{
exec("$command 2>&1", $output);
return $output;
}
function InstallSoftware()
{
$tmp ="Brah tmp variable";
$cmds = array("opkg update", "opkg install block-mount e2fsprogs kmod-fs-ext4 kmod-usb-storage-extras");
if(empty(cmd("opkg list block-mount")))
{
$tmp = cmd($cmds[0]);
sleep(10); //Wait 10 seconds to allow the opkg Update
$tmp = cmd($cmd[1]);
}
return true;
}
function FormatDrive($drive = "/dev/sda1")
{
$tmp ="Brah tmp variable";
$tmp = cmd("mkfs.ext4 -F $drive");
}
function MoveOverlay($drive = "/dev/sda1")
{
$tmp ="Brah tmp variable";
$cmds = array("mkdir /mnt/sda1", "mount /dev/sda1 /mnt/sda1",
"mount /dev/sda1 /mnt ; tar -C /overlay -cvf - . | tar -C /mnt -xf - ; umount /mnt",
"block detect > /etc/config/fstab");
FormatDrive($drive);
$tmp = cmd($cmds[0]);
$tmp = cmd($cmds[1]);
$tmp = cmd($cmds[2]);
sleep(10); //Wait 10 seconds to copy /overlay to /dev/sda1
$tmp = cmd($cmds[3]);
}
if(!InstallSoftware())
{
MoveOverlay("/dev/sda1");
echo "DONE: now run vi /etc/config/fstab and change <br />"
+ "<strong>option target '/mnt/sda1'</strong> TO: <strong>option target '/overlay'</strong> <br />"+
"Then change <strong>option enabled 0</strong> TO: <strong>option enabled 1</strong>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment