Skip to content

Commit

Permalink
PUSH
Browse files Browse the repository at this point in the history
-> Added a auto update script
-> Added a version checker on stats page
  • Loading branch information
NaysKutzu committed Nov 22, 2023
1 parent 16fe8ed commit 5613fca
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
24 changes: 24 additions & 0 deletions update.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

cd /var/www/mythicaldash
mariadb-dump -p mythicaldash > mythicaldash_backup.sql
cd /var/www
file_name="clientbackup.zip"

if [ -e "$file_name" ]; then
rm "$file_name"
echo "$file_name deleted successfully."
else
echo "$file_name does not exist."
fi
zip -r clientbackup.zip mythicaldash/

cd /var/www/mythicaldash
curl -Lo MythicalDash.zip https://github.com/mythicalltd/mythicaldash/releases/latest/download/MythicalDash.zip
unzip -o MythicalDash.zip -d /var/www/mythicaldash
dos2unix arch.bash
sudo bash arch.bash
rm /var/www/mythicaldash/public/FIRST_USER
composer install --no-dev --optimize-autoloader
./MythicalDash -migrate
chown -R www-data:www-data /var/www/mythicaldash/*
43 changes: 41 additions & 2 deletions view/admin/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
</head>

<body>
<div id="preloader" class="discord-preloader">
<!--<div id="preloader" class="discord-preloader">
<div class="spinner"></div>
</div>
</div>-->
<div class="layout-wrapper layout-content-navbar">
<div class="layout-container">
<?php include(__DIR__ . '/../components/sidebar.php') ?>
Expand All @@ -52,6 +52,45 @@
<div class="container-xxl flex-grow-1 container-p-y">
<h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light">Admin /</span> Statistics</h4>
<?php include(__DIR__ . '/../components/alert.php') ?>
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.github.com/repos/mythicalltd/mythicaldash/releases/latest");
curl_setopt($ch, CURLOPT_HTTPHEADER, ['User-Agent: MythicalDash']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data && isset($data['tag_name'])) {
$latestVersion = $data['tag_name'];
$pr = $data['prerelease'];
if ($pr == true) {
$pre = " (Prerelease)";
} else {
$pre = null;
}
if ($latestVersion == SettingsManager::getSetting("version")) {
?>
<div class="alert alert-success " role="alert">
You are up to date!
<br><br> Branch: <code><?= $data['target_commitish'] ?></code> <br>Version: <code><?php echo $data['tag_name'].$pre ?></code>
</div>
<?php
} else {
?>
<div class="alert alert-danger " role="alert">
You are not up-to-date with your MythicalDash installation, make sure to update <a
href="https://docs.mythicalsystems.me/docs/MythicalDash/upgrade">here</a>.
</div>
<?php
}
} else {
?>
<div class="alert alert-danger " role="alert">
Failed to get the info about MythicalDash version system.
</div>
<?php
}
?>
<div class="">
<!-- Statistics -->
<div class="card h-100">
Expand Down

0 comments on commit 5613fca

Please sign in to comment.