tiny-slitaz annotate step1.php @ rev 22

more /tmp wipe
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Sep 30 10:59:00 2017 +0200 (2017-09-30)
parents 694b6eb6f4f9
children 974cf6a79cc4
rev   line source
pascal@0 1 <?php
pascal@0 2
pascal@5 3 shell_exec("sudo ./helper --chkdist");
pascal@0 4 $usedvars = array( "kernel", "modules", "packages", "toconfigure",
pascal@0 5 "continue", "configuring", "tmp_dir" );
pascal@0 6
pascal@0 7 function set_tmp_dir()
pascal@0 8 {
pascal@0 9 $dir = opendir("/tmp");
pascal@19 10 $i = 0;
pascal@0 11 while (($name = readdir($dir)) !== false) {
pascal@0 12 if (preg_match('/^tiny_webgen/',$name) == 0) continue;
pascal@22 13 if (filemtime("/tmp/$name") < strtotime("-1 hour"))
pascal@22 14 shell_exec("sudo ./helper --remove /tmp/$name");
pascal@22 15 else if ($i++ > 100) {
paul@20 16 echo "<h1>Too many users, retry later</h1>";
pascal@19 17 exit;
pascal@19 18 }
pascal@0 19 }
pascal@0 20 closedir($dir);
pascal@0 21 if (isset($_POST["tmp_dir"])) return;
pascal@0 22 $_POST["tmp_dir"] = tempnam('','tiny_webgen');
pascal@0 23 if (file_exists($_POST["tmp_dir"])) unlink($_POST["tmp_dir"]);
pascal@0 24 mkdir($_POST["tmp_dir"]);
pascal@0 25 $_POST["tmp_dir"] .= '/';
pascal@0 26 }
pascal@0 27
pascal@0 28 set_tmp_dir();
pascal@0 29
pascal@0 30 function post_hidden()
pascal@0 31 {
pascal@0 32 global $usedvars;
pascal@0 33 foreach ($usedvars as $var) {
pascal@0 34 if (isset($_POST[$var]) && $var != "continue" &&
pascal@0 35 $var != "configuring") {
pascal@0 36 ?>
pascal@0 37 <input name="<?php echo $var; ?>" value="<?php echo $_POST[$var]; ?>" type="hidden" />
pascal@0 38 <?php
pascal@0 39 }
pascal@0 40 }
pascal@0 41 }
pascal@0 42
pascal@0 43 function upload($var, $file = "")
pascal@0 44 {
pascal@0 45 if ($file == "") $file = $var;
pascal@0 46 if (isset($_FILES[$var])) {
pascal@0 47 $tmp_name = $_FILES[$var]['tmp_name'];
pascal@0 48 if (is_uploaded_file($tmp_name)) {
pascal@0 49 move_uploaded_file($tmp_name, $_POST["tmp_dir"].$file);
pascal@0 50 }
pascal@0 51 }
pascal@0 52 }
pascal@0 53
pascal@0 54 if (isset($_POST['mykernel']) && !isset($_POST['packages'])) {
pascal@0 55 $_POST['kernel'] = "custom";
pascal@0 56 upload("uploadkernel","kernel");
pascal@0 57 }
pascal@0 58
pascal@0 59 if (!isset($_POST['kernel'])) {
pascal@1 60 shell_exec("sudo ./helper --init");
pascal@0 61 if (isset($_POST['config'])) {
pascal@0 62 upload("uploadconf");
pascal@0 63 }
pascal@0 64 if (!file_exists($_POST["tmp_dir"]."uploadconf")) {
pascal@0 65 ?>
pascal@0 66
pascal@6 67 <div class="box">
pascal@6 68 <h3>[Step 1/5] Packages and Kernel</h3>
pascal@6 69
pascal@6 70 <p>The file <tt>/etc/packages.conf</tt> in the initramfs holds all information
pascal@6 71 to rebuild your Tiny SliTaz system. You should upload your
paul@17 72 <tt>/etc/packages.conf</tt> first if you only want to upgrade your system.</p>
pascal@0 73
pascal@0 74 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
pascal@6 75 Packages configuration:
pascal@6 76 <input type="file" name="uploadconf" />
pascal@6 77 <input name="config" value="Get config" type="submit" />
pascal@6 78 <?php post_hidden(); ?>
pascal@0 79 </form>
pascal@0 80 <?php
pascal@0 81 }
pascal@0 82 if (isset($_POST['mypackages'])) {
pascal@0 83 upload("uploadpkgs");
pascal@0 84 shell_exec("./helper --pkgs-extract uploadpkgs ".$_POST['tmp_dir']);
pascal@0 85 }
pascal@0 86 if (!file_exists($_POST["tmp_dir"]."uploadpkgs")) {
pascal@0 87 ?>
pascal@0 88
pascal@6 89 <hr>
pascal@6 90
pascal@6 91 <p>You can upload a tazpkg file (.tazpkg) or a tarball of tazpkg files (.tar).
pascal@0 92 These packages will extend the official packages list and will be chosen when
pascal@0 93 the package names are found to be matching. You can find some examples in the
pascal@6 94 <a href="http://hg.slitaz.org/wok-tiny/file/">Tiny SliTaz repository</a>.</p>
pascal@6 95
pascal@0 96 <div>
pascal@6 97 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
pascal@6 98 Additional packages:
pascal@6 99 <input type="file" name="uploadpkgs" />
pascal@6 100 <input name="mypackages" value="Get packages" type="submit" />
pascal@6 101 <?php post_hidden(); ?>
pascal@6 102 </form>
pascal@0 103 </div>
pascal@6 104
pascal@6 105 <hr>
pascal@0 106 <?php
pascal@0 107 }
pascal@0 108 ?>
pascal@0 109
pascal@6 110 <p id="kernel">You can upload a custom Kernel or use an official one. Your
pascal@6 111 Kernel should have an embedded initramfs with busybox like <a
paul@17 112 href="dist/rootfs.cpio" title="See CONFIG_INITRAMFS_SOURCE">this</a>.</p>
pascal@0 113
pascal@0 114 <div>
pascal@6 115 <form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
pascal@6 116 Custom kernel (bzImage file):
pascal@6 117 <input type="file" name="uploadkernel" />
pascal@6 118 <input name="mykernel" value="Get kernel" type="submit" />
pascal@6 119 <?php post_hidden(); ?>
pascal@6 120 </form>
pascal@0 121 </div>
pascal@0 122
pascal@6 123 <hr>
pascal@6 124
pascal@0 125 <div>
pascal@6 126 <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" name="kernels">
pascal@6 127 <input type="hidden" name="kernel" value="linux" />
pascal@19 128 <?php post_hidden(); ?>
pascal@6 129 <div align="center">
pascal@6 130 <input name="continue" value="Continue" type="submit" />
pascal@6 131 </div>
pascal@6 132 </form>
pascal@0 133 </div>
pascal@0 134 </div>
pascal@6 135
pascal@0 136 <?php
pascal@0 137 }
pascal@0 138 ?>
pascal@0 139