|
|
@@ -0,0 +1,71 @@
|
|
|
+#!/usr/bin/php
|
|
|
+<?php
|
|
|
+echo "[NOTE] Make sure the directories you install to are R+W accessible by your web server.\n";
|
|
|
+$user_info = posix_getpwuid(posix_geteuid());
|
|
|
+echo "Please enter the directory you wish for tCMS' private data files to be stored under.\n";
|
|
|
+echo "Default [" . $user_info['dir'] . "/.tCMS]: ";
|
|
|
+$input = get_string_from_stdin();
|
|
|
+if( empty( $input ) ) {
|
|
|
+ $private_base = $user_info['dir'] . "/.tCMS";
|
|
|
+} else {
|
|
|
+ # At least *try* to get the real path. If not, can't do much other than trust it works.
|
|
|
+ $private_base = realpath( dirname( $input ) ) . "/" . basename( $input );
|
|
|
+}
|
|
|
+echo "Please enter the directory you wish for tCMS' public data files to be stored under.\n";
|
|
|
+echo "Default [" . $user_info['dir'] . "/public_html]: ";
|
|
|
+$input = get_string_from_stdin();
|
|
|
+if( empty( $input ) ) {
|
|
|
+ $public_base = $user_info['dir'] . "/public_html";
|
|
|
+} else {
|
|
|
+ $public_base = realpath( dirname( $input ) ) . "/" . basename( $input );
|
|
|
+}
|
|
|
+# Make sure our webserver (and my horrible code) knows how to find your custom directory
|
|
|
+if( $private_base != $user_info['dir'] . "/.tCMS" ) {
|
|
|
+ echo "[WARN]: For tCMS to know where this directory we install to is, we will write the following\n";
|
|
|
+ echo " into your document root for the default/virtual host you control on your Web Server:\n";
|
|
|
+ echo " '$public_base/basedir'\n";
|
|
|
+ echo " Please add an HTACCESS or similar blocker to prevent public acess to this file if you\n";
|
|
|
+ echo " wish to prevent this information disclosure. Please press [enter] to continue.";
|
|
|
+ get_string_from_stdin(); # Mostly just to make the user confirm they read this.
|
|
|
+}
|
|
|
+$wd = realpath( dirname( __FILE__ ) . "/../" );
|
|
|
+echo "[INFO] Installing private data to $private_base now...\n";
|
|
|
+$files = [ 'lib', 'templates' ];
|
|
|
+install( $private_base, $wd, $files );
|
|
|
+foreach ( [ "$private_base/blog", "$private_base/microblog" ] as $dir ) {
|
|
|
+ if ( !file_exists( $dir ) ) mkdir( $dir );
|
|
|
+}
|
|
|
+echo "[INFO] Installing public data to $public_base now...\n";
|
|
|
+$files = [ 'css', 'fileshare', 'img', 'index.php', 'sys' ];
|
|
|
+install( $public_base, $wd, $files );
|
|
|
+if( $private_base != $user_info['dir'] . "/.tCMS" ) {
|
|
|
+ file_put_contents( "$public_base/basedir", $private_base );
|
|
|
+}
|
|
|
+echo "[INFO] Done.\n";
|
|
|
+exit(0);
|
|
|
+
|
|
|
+function get_string_from_stdin() {
|
|
|
+ $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 );
|
|
|
+ return $input;
|
|
|
+}
|
|
|
+
|
|
|
+function install( $to, $from, $files2copy ) {
|
|
|
+ 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;
|
|
|
+}
|
|
|
+?>
|