2017-09-25 20:30:18 -07:00
|
|
|
<?php
|
|
|
|
(PHP_SAPI !== 'cli' || isset($_SERVER['HTTP_USER_AGENT'])) && die('Access denied.');
|
|
|
|
|
2017-09-26 13:11:01 -07:00
|
|
|
$pwu_data = posix_getpwuid(posix_geteuid());
|
|
|
|
$username = $pwu_data['name'];
|
|
|
|
|
|
|
|
if (($username=='root') || ($username=='admin')) {
|
|
|
|
die("\nERROR: This script should not be run as root/admin. Exiting.\n\n");
|
|
|
|
}
|
|
|
|
|
2017-09-25 20:30:18 -07:00
|
|
|
echo "Welcome to the Snipe-IT upgrader.\n\n";
|
2017-09-26 13:05:34 -07:00
|
|
|
echo "Please note that this script will not download the latest Snipe-IT \n";
|
|
|
|
echo "files for you, it simply runs the standard composer and artisan \n";
|
|
|
|
echo "commands needed to finalize the upgrade after \n\n";
|
2017-09-25 20:30:18 -07:00
|
|
|
|
2017-09-26 13:05:34 -07:00
|
|
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
|
|
|
|
echo "!! If you have any encrypted custom fields, BE SURE TO run the recrypter. \n";
|
|
|
|
echo "!! See the Snipe-IT documentation for help: \n";
|
|
|
|
echo "!! https://snipe-it.readme.io/docs/upgrading-to-v4\n";
|
|
|
|
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
|
2017-09-25 20:30:18 -07:00
|
|
|
|
|
|
|
echo "--------------------------------------------------------\n";
|
|
|
|
echo "STEP 1: Backing up database: \n";
|
|
|
|
echo "--------------------------------------------------------\n\n";
|
|
|
|
$backup = shell_exec('php artisan snipeit:backup');
|
2017-09-26 13:05:34 -07:00
|
|
|
echo '-- '.$backup."\n\n";
|
2017-09-25 20:30:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
echo "--------------------------------------------------------\n";
|
|
|
|
echo "STEP 2: Putting application into maintenance mode: \n";
|
|
|
|
echo "--------------------------------------------------------\n\n";
|
|
|
|
$down = shell_exec('php artisan down');
|
2017-09-26 13:05:34 -07:00
|
|
|
echo '-- '.$down."\n\n";
|
2017-09-25 20:30:18 -07:00
|
|
|
|
|
|
|
echo "--------------------------------------------------------\n";
|
|
|
|
echo "Step 3: Cleaning up old cached files:\n";
|
|
|
|
echo "--------------------------------------------------------\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
if (file_exists('bootstrap/cache/compiled.php')) {
|
|
|
|
echo "-- Deleting bootstrap/cache/compiled.php. It it no longer used.\n";
|
|
|
|
@unlink('bootstrap/cache/compiled.php');
|
|
|
|
} else {
|
|
|
|
echo "-- No bootstrap/cache/compiled.php, so nothing to delete.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file_exists('bootstrap/cache/services.php')) {
|
|
|
|
echo "-- Deleting bootstrap/cache/services.php. It it no longer used.\n";
|
|
|
|
@unlink('bootstrap/cache/services.php');
|
|
|
|
} else {
|
|
|
|
echo "-- No bootstrap/cache/services.php, so nothing to delete.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file_exists('bootstrap/cache/config.php')) {
|
|
|
|
echo "-- Deleting bootstrap/cache/config.php. It it no longer used.\n";
|
|
|
|
@unlink('bootstrap/cache/config.php');
|
|
|
|
} else {
|
|
|
|
echo "-- No bootstrap/cache/config.php, so nothing to delete.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$config_clear = shell_exec('php artisan config:clear');
|
|
|
|
$cache_clear = shell_exec('php artisan cache:clear');
|
2017-09-26 13:05:34 -07:00
|
|
|
$route_clear = shell_exec('php artisan route:clear');
|
|
|
|
$view_clear = shell_exec('php artisan view:clear');
|
|
|
|
echo '-- '.$config_clear;
|
|
|
|
echo '-- '.$cache_clear;
|
|
|
|
echo '-- '.$route_clear;
|
|
|
|
echo '-- '.$view_clear;
|
2017-09-25 20:30:18 -07:00
|
|
|
echo "\n";
|
|
|
|
|
|
|
|
echo "--------------------------------------------------------\n";
|
2017-09-25 21:50:41 -07:00
|
|
|
echo "Step 4: Updating composer dependencies:\n";
|
|
|
|
echo "(This may take an moment.)\n";
|
2017-09-25 20:30:18 -07:00
|
|
|
echo "--------------------------------------------------------\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
// Composer install
|
|
|
|
if (file_exists('composer.phar')) {
|
2017-09-26 13:05:34 -07:00
|
|
|
echo "-- Local composer.phar detected, so we'll use that.\n\n";
|
|
|
|
$composer_dump = shell_exec('php composer.phar dump');
|
2017-09-25 20:30:18 -07:00
|
|
|
$composer = shell_exec('php composer.phar install --prefer-source');
|
2017-09-26 13:05:34 -07:00
|
|
|
|
2017-09-25 20:30:18 -07:00
|
|
|
} else {
|
2017-09-26 13:05:34 -07:00
|
|
|
echo "-- We couldn't find a local composer.phar - trying globally.\n\n";
|
|
|
|
$composer_dump = shell_exec('composer dump');
|
2017-09-25 20:30:18 -07:00
|
|
|
$composer = shell_exec('composer install --prefer-source');
|
|
|
|
}
|
|
|
|
|
2017-09-26 13:05:34 -07:00
|
|
|
echo $composer_dump."\n\n";
|
2017-09-25 20:30:18 -07:00
|
|
|
echo $composer."\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
echo "--------------------------------------------------------\n";
|
|
|
|
echo "Step 5: Migrating database:\n";
|
|
|
|
echo "--------------------------------------------------------\n\n";
|
|
|
|
|
|
|
|
$migrations = shell_exec('php artisan migrate --force');
|
2017-09-26 13:05:34 -07:00
|
|
|
echo '-- '.$migrations."\n\n";
|
2017-09-25 20:30:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
echo "--------------------------------------------------------\n";
|
|
|
|
echo "Step 6: Checking for OAuth keys:\n";
|
|
|
|
echo "--------------------------------------------------------\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
if ((!file_exists('storage/oauth-public.key')) || (!file_exists('storage/oauth-private.key'))) {
|
|
|
|
echo "- No OAuth keys detected. Running passport install now.\n\n";
|
|
|
|
$passport = shell_exec('php artisan passport:install');
|
|
|
|
echo $passport;
|
|
|
|
} else {
|
|
|
|
echo "- OAuth keys detected. Skipping passport install.\n\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo "--------------------------------------------------------\n";
|
2017-09-26 13:05:34 -07:00
|
|
|
echo "Step 7: Caching routes and config:\n";
|
|
|
|
echo "--------------------------------------------------------\n\n";
|
|
|
|
$config_cache = shell_exec('php artisan config:cache');
|
|
|
|
$route_cache = shell_exec('php artisan route:cache');
|
|
|
|
echo '-- '.$config_cache;
|
|
|
|
echo '-- '.$route_cache;
|
|
|
|
echo "\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "--------------------------------------------------------\n";
|
|
|
|
echo "Step 8: Taking application out of maintenance mode:\n";
|
2017-09-25 20:30:18 -07:00
|
|
|
echo "--------------------------------------------------------\n\n";
|
|
|
|
|
|
|
|
$up = shell_exec('php artisan up');
|
2017-09-26 13:05:34 -07:00
|
|
|
echo '-- '.$up."\n\n";
|
2017-09-25 20:30:18 -07:00
|
|
|
|
2017-09-25 21:50:41 -07:00
|
|
|
echo "--------------------------------------------------------\n";
|
|
|
|
echo "FINISHED! Clear your browser cookies and re-login to use :\n";
|
|
|
|
echo "your upgraded Snipe-IT.\n";
|
|
|
|
echo "--------------------------------------------------------\n\n";
|
2017-09-25 20:30:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
|