#!/usr/bin/env php [ 'auth_hash' => $auth_hash ] ] ) ); } echo "[INFO] Installing public data to $public_base now...\n"; $files = [ 'themed', 'fileshare', 'index.php', 'sys' ]; install( $public_base, $wd, $files ); echo "[INFO] Done.\n"; exit(0); function get_string_from_stdin($noecho=0) { if( $noecho ) system('stty -echo'); $STDIN = fopen( "php://stdin", "r" ); $input = fgets( $STDIN, 4096 ); # Not gonna read something longer than the maximum path length for ext $input = rtrim( $input ); # Trim any trailing spaces fclose( $STDIN ); if( $noecho ) system('stty echo'); return $input; } function install( $to, $from, $files2copy ) { if( empty($to) || empty($from) || empty($files2copy) ) die("Bad arguments passed to 'install' function"); if( file_exists( $to ) && !is_dir( $to ) ) { echo "[FATAL] $to already exists but is not a directory! Stopping here.\n"; exit(1); } if ( !file_exists( $to ) ) mkdir( $to ); # XXX Prolly won't work on directories foreach ( $files2copy as $file ) { # Referencing it by path as some systems have aliases on this command $cmd = "/bin/cp -rf '$from/$file' '$to/'"; echo "exec `$cmd`\n"; $out = shell_exec($cmd); echo $out; } return; } function ensure_directories_exist( $dirs ) { if( empty( $dirs ) ) die("Bad arguments passed to 'ensure_directories_exist' function"); foreach ( $dirs as $dir ) { if ( !file_exists( $dir ) ) { echo "exec `/bin/mkdir '$dir'`\n"; mkdir( $dir ); } } return; } ?>