#!/usr/bin/php -- Gets and outputs the values in the supplied JSON file.\n"; $help .= " validate -- Compares your config versus the model (sanity check).\n"; $help .= " set ... -- Sets the requested config KEY(s) to VALUE(s).\n"; echo $help; break; case "install": echo "[INFO] Some of this function is unimplemented -- for now I'm just making things for testing.\n"; $user_info = posix_getpwuid(); $basedir = $user_info['dir'] . "/.tCMS"; if( !file_exists( $basedir ) ) { if( !is_dir( $basdir ) ) { echo "[FATAL] ~/.tCMS already exists but is not a directory! Stopping here.\n"; exit(1); } else { $dirs = [ $basedir, "$basedir/bin", "$basedir/lib", "$basedir/conf", "$basedir/themes", "$basedir/microblog", "$basedir/blog", "$basedir/fileshare" ]; foreach ( $dirs as $dir ) { mkdir( $dir ); } } # Handle first time install, assume we're being ran via Makefile $install_base = realpath( dirname( __FILE__ ) ); $files2copy = [ "bin/configure-tCMS"]; foreach ( $files2copy as $file ) { if( !copy( "$install_base/$file", "$basedir/$file" ) ) { echo "[FATAL] $file couldnt' be installed!"; exit(1); } } } else { echo "[INFO] tCMS appears to already be installed. Nothing to do...\n"; exit(0); } # TODO keep going here case "get": if( empty( $argv[2] ) ) { echo "[ERROR] get was passed but no file was passed to get!\n"; exit(1); } $config_file = realpath( $argv[2] ); $config = configure::get_config_values( $config_file ); print_r( $config ); break; case "set": echo "[INFO] Unimplemented\n"; break; case "validate": if( empty( $argv[2] ) ) { echo "[ERROR] validate was passed but no file was passed to validate against!\n"; exit(1); } $config_file = realpath( $argv[2] ); $config = configure::get_config_values( $config_file ); $valid = configure::validate_config( $config ); echo ( $valid ) ? "[INFO] Config OK\n" : "[ERROR] Config NOT OK.\n"; exit( $valid ); } exit(0); } ?>