diff --git a/scripts/cloneRepository.php b/scripts/cloneRepository.php index b7198ef..74f4580 100755 --- a/scripts/cloneRepository.php +++ b/scripts/cloneRepository.php @@ -22,6 +22,9 @@ echo "Installing dev dependencies for joindin-vm\n"; system('composer install'); +echo "Updating configuration files with defaults\n"; +copyApiConfigs($repositoryToClone[0]); +copyWebConfigs($repositoryToClone[1]); function getGitUsername(string $remoteString, bool $useHttps): string { @@ -93,3 +96,30 @@ function installViaComposer(string $repoName): void echo $remoteCommand. "\n"; system($remoteCommand); } + +function copyApiConfigs(string $repoName): void +{ + $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . $repoName; + chdir($path); + + if (!file_exists('src/config.php')) { + echo 'Creating default API config' . PHP_EOL; + system("cp $path/src/config.php.dist $path/src/config.php"); + } + + if (!file_exists('src/database.php')) { + echo 'Creating default API database config' . PHP_EOL; + system("cp $path/src/database.php.dist $path/src/database.php"); + } +} + +function copyWebConfigs(string $repoName): void +{ + $path = dirname(__DIR__) . DIRECTORY_SEPARATOR . $repoName; + chdir($path); + + if (!file_exists('config/config.php')) { + echo 'Creating default Web config' . PHP_EOL; + system("cp $path/config/config.php.dist $path/config/config.php"); + } +} diff --git a/scripts/fixConfig.sh b/scripts/fixConfig.sh index 72599b0..6f339c0 100644 --- a/scripts/fixConfig.sh +++ b/scripts/fixConfig.sh @@ -2,20 +2,5 @@ VAGRANT_DIR=$PWD; -if [[ ! -e $VAGRANT_DIR/joindin-api/src/config.php ]]; then - echo "api config missing... fixing"; - cp $VAGRANT_DIR/joindin-api/src/config.php.dist $VAGRANT_DIR/joindin-api/src/config.php; -fi - -if [[ ! -f $VAGRANT_DIR/joindin-api/src/database.php ]]; then - echo "api database-config missing... fixing"; - cp $VAGRANT_DIR/joindin-api/src/database.php.dist $VAGRANT_DIR/joindin-api/src/database.php; -fi - -if [[ ! -f $VAGRANT_DIR/joindin-web2/config/config.php ]]; then - echo "Web config missing... fixing"; - cp $VAGRANT_DIR/joindin-web2/config/config.php.dist $VAGRANT_DIR/joindin-web2/config/config.php; -fi - sed -i 's/https:\/\/m.joind.in/http:\/\/dev.joind.in/' $VAGRANT_DIR/joindin-api/src/config.php sed -i 's/https:\/\/api.joind.in/http:\/\/api.dev.joind.in/' $VAGRANT_DIR/joindin-web2/config/config.php