public function setInstallInfoFromGit() { $tags = git::getTagsModule($this->installInfo['NAME'], 'template'); if (empty($tags)) { $latest = 'master'; } else { $latest = array_pop($tags); } $this->installInfo['VERSION'] = $latest; }
function cos_upgrade($options) { moduleloader::includeModule('system'); $p = new profile(); if (git::isMaster()) { common::abort('Can not make upgrade from master branch'); } $repo = conf::getModuleIni('system_repo'); $remote = git::getTagsRemoteLatest($repo); if ($p->upgradePossible()) { common::echoMessage("Latest version/tag: {$remote}", 'y'); $continue = common::readlineConfirm('Continue the upgrade'); if ($continue) { cos_upgrade_to($remote); } } else { $locale = git::getTagsInstallLatest(); common::echoMessage("Latest version/tag: {$locale}", 'y'); $continue = common::readlineConfirm('Continue. Maybe your upgrade was interrupted. '); if ($continue) { cos_upgrade_to($remote); } } }
/** * Check tags to see if we should upgrade. * @return boolean $res */ public function upgradePossible() { $locale = git::getTagsInstallLatest(); $repo = conf::getModuleIni('system_repo'); $remote = git::getTagsRemoteLatest($repo); if ($remote > $locale) { return true; } return false; }
/** * function for doing a prompt install from shell mode * is a wrapper around other shell functions. */ function prompt_install() { common::echoMessage('Pick a version to install:', 'y'); $tags = git::getTagsInstallLatest() . PHP_EOL; $tags .= "master"; common::echoMessage($tags); $tag = common::readSingleline("Enter tag (version) to use:"); common::execCommand("git checkout {$tag}"); // Which profile to install $profiles = file::getFileList('profiles', array('dir_only' => true)); if (count($profiles) == 1) { $profile = array_pop($profiles); } else { common::echoMessage("List of profiles: "); foreach ($profiles as $val) { common::echoMessage("\t" . $val); } // select profile and load it $profile = common::readSingleline('Enter profile, and hit return: '); } common::echoMessage("Loading the profile '{$profile}'", 'y'); load_profile(array('profile' => $profile, 'config_only' => true)); common::echoMessage("Main configuration (placed in config/config.ini) for '{$profile}' is loaded", 'y'); // Keep base path. Ortherwise we will lose it when loading profile $base_path = conf::pathBase(); // Load the default config.ini settings as a skeleton conf::$vars['coscms_main'] = conf::getIniFileArray($base_path . '/config/config.ini', true); // Reset base path conf::setMainIni('base_path', $base_path); conf::defineCommon(); common::echoMessage("Enter MySQL credentials", 'y'); // Get configuration info $host = common::readSingleline('Enter your MySQL host: '); $database = common::readSingleline('Enter database name: '); $username = common::readSingleline('Enter database user: '******'Enter database users password: '******'Enter server host name: '); common::echoMessage("Writing database connection info to main configuration"); // Assemble configuration info conf::$vars['coscms_main']['url'] = "mysql:dbname={$database};host={$host};charset=utf8"; conf::$vars['coscms_main']['username'] = $username; conf::$vars['coscms_main']['password'] = $password; conf::$vars['coscms_main']['server_name'] = $server_name; // Write it to ini file $content = conf::arrayToIniFile(conf::$vars['coscms_main'], false); $path = conf::pathBase() . "/config/config.ini"; file_put_contents($path, $content); common::echoMessage("Your can also always change the config/config.ini file manually"); $options = array(); $options['profile'] = $profile; if ($tag == 'master') { $options['master'] = true; } common::echoMessage("Will now clone and install all modules", 'y'); cos_install($options); common::echoMessage("Create a super user", 'y'); useradd_add(); $login = "******"; common::echoMessage("If there was no errors you will be able to login at {$login}"); common::echoMessage("Remember to change file permissions. This will require super user"); common::echoMessage("E.g. like this:"); common::echoMessage("sudo ./coscli.sh file --chmod-files"); }
/** * function for showing git tags (just for testing) * @param array $options */ function cos_git_echo_remote_tags($options) { if (empty($options['repo'])) { common::abort('You need to specify a repo'); } $tags = git::getTagsRemote($options['repo']); if (empty($tags)) { common::abort('No tags'); } $latest = git::getTagsRemoteLatest($options['repo']); common::echoMessage("Latest is: {$latest}"); }