From 0c3c59df4e3093b98e814cb68fd051d7313d6156 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Tue, 3 Aug 2021 17:42:57 +0800 Subject: [PATCH 001/207] Fix: [DB] Add default for created_date in monitor --- db/patch5.sql | 66 ++++++++++++++++++++++++++++++++++++++++++++++ server/database.js | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 db/patch5.sql diff --git a/db/patch5.sql b/db/patch5.sql new file mode 100644 index 0000000..f67af8b --- /dev/null +++ b/db/patch5.sql @@ -0,0 +1,66 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +PRAGMA foreign_keys = off; + +BEGIN TRANSACTION; + +create table monitor_dg_tmp ( + id INTEGER not null primary key autoincrement, + name VARCHAR(150), + active BOOLEAN default 1 not null, + user_id INTEGER references user on update cascade on delete + set + null, + interval INTEGER default 20 not null, + url TEXT, + type VARCHAR(20), + weight INTEGER default 2000, + hostname VARCHAR(255), + port INTEGER, + created_date DATETIME default (DATETIME('now')) not null, + keyword VARCHAR(255), + maxretries INTEGER NOT NULL DEFAULT 0, + ignore_tls BOOLEAN default 0 not null, + upside_down BOOLEAN default 0 not null +); + +insert into + monitor_dg_tmp( + id, + name, + active, + user_id, + interval, + url, + type, + weight, + hostname, + port, + keyword, + maxretries + ) +select + id, + name, + active, + user_id, + interval, + url, + type, + weight, + hostname, + port, + keyword, + maxretries +from + monitor; + +drop table monitor; + +alter table + monitor_dg_tmp rename to monitor; + +create index user_id on monitor (user_id); + +COMMIT; + +PRAGMA foreign_keys = on; \ No newline at end of file diff --git a/server/database.js b/server/database.js index 571313b..4accbc3 100644 --- a/server/database.js +++ b/server/database.js @@ -9,7 +9,7 @@ class Database { static templatePath = "./db/kuma.db" static path = "./data/kuma.db"; - static latestVersion = 4; + static latestVersion = 5; static noReject = true; static async patch() { From 377d475e05e6fc5374634d6e18ff957adf59b296 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Tue, 3 Aug 2021 17:43:39 +0800 Subject: [PATCH 002/207] Fix: Add now columns --- db/patch5.sql | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db/patch5.sql b/db/patch5.sql index f67af8b..16e1c28 100644 --- a/db/patch5.sql +++ b/db/patch5.sql @@ -36,7 +36,9 @@ insert into hostname, port, keyword, - maxretries + maxretries, + ignore_tls, + upside_down ) select id, @@ -50,7 +52,9 @@ select hostname, port, keyword, - maxretries + maxretries, + ignore_tls, + upside_down from monitor; From 221aad55de4f7350221032f7c21854eca35b1981 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Tue, 3 Aug 2021 17:46:09 +0800 Subject: [PATCH 003/207] Chore: Add new line at EOF --- db/patch5.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/patch5.sql b/db/patch5.sql index 16e1c28..5730b2d 100644 --- a/db/patch5.sql +++ b/db/patch5.sql @@ -67,4 +67,4 @@ create index user_id on monitor (user_id); COMMIT; -PRAGMA foreign_keys = on; \ No newline at end of file +PRAGMA foreign_keys = on; From a28d6eafae8bb54b08022c63233e598cbe5b1e1d Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 3 Aug 2021 20:35:41 +0800 Subject: [PATCH 004/207] remove apprise --version from dockerfile --- dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/dockerfile b/dockerfile index 6272223..233913d 100644 --- a/dockerfile +++ b/dockerfile @@ -14,7 +14,6 @@ RUN apk add --no-cache --virtual .build-deps make g++ python3 python3-dev && \ RUN apk add --no-cache python3 py3-cryptography py3-pip py3-six py3-yaml py3-click py3-markdown py3-requests py3-requests-oauthlib RUN pip3 --no-cache-dir install apprise && \ rm -rf /root/.cache -RUN apprise --version # New things add here From f2de6299f627c44808e79313ead3e6919cdafc87 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 3 Aug 2021 20:42:32 +0800 Subject: [PATCH 005/207] update .dockerignore --- .dockerignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.dockerignore b/.dockerignore index 4ddce98..cdd61ff 100644 --- a/.dockerignore +++ b/.dockerignore @@ -18,6 +18,8 @@ README.md package-lock.json yarn.lock app.json +CODE_OF_CONDUCT.md +CONTRIBUTING.md ### .gitignore content (commented rules are duplicated) From e34a8e2e4aa2e2b0879e53a7e467d761d470d5d1 Mon Sep 17 00:00:00 2001 From: Philipp Dormann <17651032+philippdormann@users.noreply.github.com> Date: Tue, 3 Aug 2021 17:14:27 +0200 Subject: [PATCH 006/207] FEAT: PUSHY Notifier (#154) FEAT: PUSHY Notifier (#154) --- server/notification.js | 18 ++++++++++++++++++ src/components/NotificationDialog.vue | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/server/notification.js b/server/notification.js index 0e963a1..f53b681 100644 --- a/server/notification.js +++ b/server/notification.js @@ -137,6 +137,24 @@ class Notification { throwGeneralAxiosError(error) } + } else if (notification.type === "pushy") { + try { + await axios.post(`https://api.pushy.me/push?api_key=${notification.pushyAPIKey}`, { + "to": notification.pushyToken, + "data": { + "message": "Uptime-Kuma" + }, + "notification": { + "body": msg, + "badge": 1, + "sound": "ping.aiff" + } + }) + return true; + } catch (error) { + console.log(error) + return false; + } } else if (notification.type === "slack") { try { if (heartbeatJSON == null) { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 4af1ffa..4eea85d 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -21,6 +21,7 @@ + @@ -229,6 +230,23 @@ + + -
+

Notifications

@@ -201,8 +214,17 @@ export default { } - diff --git a/src/util.js b/src/util.js index 8e80cb6..4463099 100644 --- a/src/util.js +++ b/src/util.js @@ -29,7 +29,7 @@ function ucfirst(str) { exports.ucfirst = ucfirst; function debug(msg) { if (process.env.NODE_ENV === "development") { - console.log(msg); + console.debug(msg); } } exports.debug = debug; diff --git a/src/util.ts b/src/util.ts index 4d53232..1ed6d4c 100644 --- a/src/util.ts +++ b/src/util.ts @@ -39,6 +39,6 @@ export function ucfirst(str) { export function debug(msg) { if (process.env.NODE_ENV === "development") { - console.log(msg) + console.debug(msg); } } From a79e6aa338447b795956984239979a51373c0cac Mon Sep 17 00:00:00 2001 From: LouisLam Date: Sun, 8 Aug 2021 15:02:33 +0800 Subject: [PATCH 038/207] dark theme for multiselect --- src/assets/app.scss | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/assets/app.scss b/src/assets/app.scss index 0c32f2b..e70bf71 100644 --- a/src/assets/app.scss +++ b/src/assets/app.scss @@ -132,4 +132,27 @@ border-color: $dark-border-color; color: $dark-font-color; } + + // Multiselect + .multiselect__tags { + background-color: $dark-bg2; + border-color: $dark-border-color; + } + + .multiselect__input, .multiselect__single { + background-color: $dark-bg2; + color: $dark-font-color; + } + + .multiselect__content-wrapper { + background-color: $dark-bg2; + } + + .multiselect__option--selected.multiselect__option--highlight { + + } + + .multiselect__option--selected { + background-color: $dark-bg; + } } From 4ff68238c4fb19588627527cf74c14a62e8a8e2a Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Sun, 8 Aug 2021 15:04:20 +0800 Subject: [PATCH 039/207] Chore: Improve logging during db development --- server/database.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/database.js b/server/database.js index 8d6d4f5..b6e0d93 100644 --- a/server/database.js +++ b/server/database.js @@ -41,6 +41,8 @@ class Database { if (version === this.latestVersion) { console.info("Database no need to patch"); + } else if (version > this.latestVersion) { + console.info("Warning: Database version is newer than expected"); } else { console.info("Database patch is needed") From 3265c3cbc33a796a15e0b30a199c8d8e40e97502 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Sun, 8 Aug 2021 21:03:10 +0800 Subject: [PATCH 040/207] improve multiselect --- server/server.js | 3 ++- src/assets/app.scss | 16 +++++++++++++++- src/pages/EditMonitor.vue | 26 ++++++++++++++++++++++---- src/util.js | 2 +- src/util.ts | 2 +- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/server/server.js b/server/server.js index f14095e..5ebf618 100644 --- a/server/server.js +++ b/server/server.js @@ -1,4 +1,5 @@ -console.log("Welcome to Uptime Kuma") +console.log("Welcome to Uptime Kuma"); +console.log("Node Env: " + process.env.NODE_ENV); const { sleep, debug } = require("../src/util"); diff --git a/src/assets/app.scss b/src/assets/app.scss index e70bf71..45f09f0 100644 --- a/src/assets/app.scss +++ b/src/assets/app.scss @@ -5,6 +5,15 @@ font-family: ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,segoe ui,Roboto,helvetica neue,Arial,noto sans,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol,noto color emoji; } +::-webkit-scrollbar { + width: 10px; +} + +::-webkit-scrollbar-thumb { + background: #CCC; + border-radius: 20px; +} + .modal { backdrop-filter: blur(3px); } @@ -26,7 +35,7 @@ .shadow-box { - overflow: hidden; + //overflow: hidden; // Forget why add this, but multiple select hide by this box-shadow: 0 15px 70px rgba(0, 0, 0, .1); padding: 10px; border-radius: 10px; @@ -62,6 +71,10 @@ background-color: #090C10; color: $dark-font-color; + &::-webkit-scrollbar-thumb { + background: $dark-border-color; + } + .shadow-box { background-color: $dark-bg; } @@ -146,6 +159,7 @@ .multiselect__content-wrapper { background-color: $dark-bg2; + border-color: $dark-border-color; } .multiselect__option--selected.multiselect__option--highlight { diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index cd75984..576566b 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -96,9 +96,20 @@
- - - + + +
Select status codes which are considered as a successful response.
@@ -248,7 +259,7 @@ export default { @import "../assets/vars.scss"; .multiselect__tags { - border-radius: 2rem; + border-radius: 1.5rem; border: 1px solid #ced4da; } @@ -265,8 +276,15 @@ export default { } .multiselect__tag { + border-radius: 50rem; background: $primary !important; } + + .dark { + .multiselect__tag { + color: $dark-font-color2; + } + } From 974672f7c1b9b9912e0443b291dd711ae4b12054 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Tue, 10 Aug 2021 13:09:36 +0800 Subject: [PATCH 073/207] Delete deploy.template.yaml --- .do/deploy.template.yaml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .do/deploy.template.yaml diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml deleted file mode 100644 index ecbcea7..0000000 --- a/.do/deploy.template.yaml +++ /dev/null @@ -1,11 +0,0 @@ -spec: - name: uptime-kuma - services: - - name: server - git: - repo_clone_url: https://github.com/louislam/uptime-kuma - branch: master - http_port: 3001 - build_command: npm run setup - run_command: npm run start-server - From 1e4f9c7e1543799dc2845271c15fb1129c116527 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Tue, 10 Aug 2021 13:10:03 +0800 Subject: [PATCH 074/207] Update README.md --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index 794ee01..d1c8b38 100644 --- a/README.md +++ b/README.md @@ -80,15 +80,6 @@ Unlikely other web apps, Uptime Kuma is based on WebSocket. You need two more he Please read wiki for more info: https://github.com/louislam/uptime-kuma/wiki/Reverse-Proxy -### One-click Deploy - - - -[![Deploy to DO](https://www.deploytodo.com/do-btn-blue.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/louislam/uptime-kuma/tree/master&refcode=e2c7eb658434) - ## How to Update ### Docker From 9ba1743900bba33cba2f097afb3742d91801ab09 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 10 Aug 2021 15:02:46 +0800 Subject: [PATCH 075/207] split mobile mixin from socket mixin --- src/layouts/Layout.vue | 22 +++++++++++++++++++--- src/main.js | 4 +++- src/mixins/mobile.js | 25 +++++++++++++++++++++++++ src/mixins/socket.js | 9 --------- 4 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 src/mixins/mobile.js diff --git a/src/layouts/Layout.vue b/src/layouts/Layout.vue index 93ad065..d63f209 100644 --- a/src/layouts/Layout.vue +++ b/src/layouts/Layout.vue @@ -1,5 +1,5 @@ + +
-
+
@@ -153,10 +153,6 @@ export default { } } -.hideHeartbeatBar { - display: none; -} - .monitorItem { width: 100%; } From d218661f3db3231022c561de1f4c62aa1fe0ea2e Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 17 Aug 2021 23:08:35 +0800 Subject: [PATCH 143/207] wip: implementing install script --- extra/compile-install-script.ps1 | 3 +- extra/install.batsh | 69 +++++++++++++++++++++ install.sh | 52 ++++++++++++++++ package.json | 3 +- test/test_install_script/centos7.dockerfile | 9 +++ 5 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 extra/install.batsh create mode 100644 install.sh create mode 100644 test/test_install_script/centos7.dockerfile diff --git a/extra/compile-install-script.ps1 b/extra/compile-install-script.ps1 index 4b25b55..dd44798 100644 --- a/extra/compile-install-script.ps1 +++ b/extra/compile-install-script.ps1 @@ -1 +1,2 @@ -docker run -it --rm -v ${pwd}:/app louislam/batsh /usr/bin/batsh bash --output ./install.sh ./extra/install.batsh \ No newline at end of file +# Must enable File Sharing in Docker Desktop +docker run -it --rm -v ${pwd}:/app louislam/batsh /usr/bin/batsh bash --output ./install.sh ./extra/install.batsh diff --git a/extra/install.batsh b/extra/install.batsh new file mode 100644 index 0000000..005b2db --- /dev/null +++ b/extra/install.batsh @@ -0,0 +1,69 @@ +println("====================="); +println("Uptime Kuma Installer"); +println("====================="); +println(""); +println("---------------------------------------"); +println("This script is designed for Linux and basic usage."); +println("For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation"); +println("---------------------------------------"); +println(""); +println("Local - Install Uptime Kuma in your current machine with git, Node.js 14 and pm2"); +println("Docker - Install Uptime Kuma Docker container"); +println(""); + +if ("$1" != "") { + type = "$1"; +} else { + call("read", "-p", "Which installation method do you prefer? [DOCKER/local]: ", "type"); +} + +if (type == "local") { + + if ("$1" != "") { + port = "$3"; + } else { + call("read", "-p", "Listening Port [3001]: ", "port"); + } + + if (exists("/etc/redhat-release")) { + os = call("cat", "/etc/redhat-release"); + distribution = "rhel"; + } + + bash("arch=$(uname -i)"); + + println("Your OS: " ++ os); + println("Distribution: " ++ distribution); + println("Arch: " ++ arch); + + if (distribution == "rhel") { + bash("nodePath=$(command -v node)"); + + if (nodePath != "") { + bash("nodeVersion=$(node -e 'console.log(process.versions.node.split(`.`)[0])')"); + println("Node Version: " ++ nodeVersion); + + if (nodeVersion < "12") { + println("Error: Required Node.js 14"); + call("exit", "1"); + + } else { + if (nodeVersion == "12") { + println("Warning: NodeJS " ++ nodeVersion ++ " is not tested."); + } + println("OK"); + } + + } else { + + } + + + + call("yum", "install", "git", "-y"); + } + +} else { + call("read", "-p", "Expose Port [3001]: ", "port"); + call("read", "-p", "Volume Name [uptime-kuma]: ", "volume"); +} diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..8e9c828 --- /dev/null +++ b/install.sh @@ -0,0 +1,52 @@ +"echo" "-e" "=====================" +"echo" "-e" "Uptime Kuma Installer" +"echo" "-e" "=====================" +"echo" "-e" "" +"echo" "-e" "---------------------------------------" +"echo" "-e" "This script is designed for Linux and basic usage." +"echo" "-e" "For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation" +"echo" "-e" "---------------------------------------" +"echo" "-e" "" +"echo" "-e" "Local - Install Uptime Kuma in your current machine with git, Node.js 14 and pm2" +"echo" "-e" "Docker - Install Uptime Kuma Docker container" +"echo" "-e" "" +"echo" "-e" "$1" +if [ "$1" != "" ]; then + type="$1" +else + "read" "-p" "Which installation method do you prefer? [DOCKER/local]: " "type" +fi +if [ "$type" == "local" ]; then + "read" "-p" "Listening Port [3001]: " "port" + if [ -e "/etc/redhat-release" ]; then + os=$("cat" "/etc/redhat-release") + distribution="rhel" +fi + arch=$(uname -i) + "echo" "-e" "Your OS: ""$os" + "echo" "-e" "Distribution: ""$distribution" + "echo" "-e" "Arch: ""$arch" + if [ "$distribution" == "rhel" ]; then + nodePath=$(command -v node) + if [ "$nodePath" != "" ]; then + nodeVersion=$(node -e 'console.log(process.versions.node.split(`.`)[0])') + "echo" "-e" "Node Version: ""$nodeVersion" + _0="12" + if [ $(($nodeVersion < $_0)) == 1 ]; then + "echo" "-e" "Error: Required Node.js 14" + "exit" "1" + else + if [ "$nodeVersion" == "12" ]; then + "echo" "-e" "Warning: NodeJS ""$nodeVersion"" is not tested." +fi + "echo" "-e" "OK" + fi + else +- + fi + "yum" "install" "git" "-y" +fi +else + "read" "-p" "Expose Port [3001]: " "port" + "read" "-p" "Volume Name [uptime-kuma]: " "volume" +fi diff --git a/package.json b/package.json index 8918068..c0ef04f 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "update-version": "node extra/update-version.js", "mark-as-nightly": "node extra/mark-as-nightly.js", "reset-password": "node extra/reset-password.js", - "compile-install-script": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./extra/compile-install-script.ps1" + "compile-install-script": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./extra/compile-install-script.ps1", + "test-install-script": "docker build --no-cache -f test/test_install_script/centos7.dockerfile ." }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^1.2.36", diff --git a/test/test_install_script/centos7.dockerfile b/test/test_install_script/centos7.dockerfile new file mode 100644 index 0000000..ef3ec5b --- /dev/null +++ b/test/test_install_script/centos7.dockerfile @@ -0,0 +1,9 @@ +FROM centos:7 + +RUN useradd -ms /bin/bash test_user +USER test_user +WORKDIR /home/test_user + +COPY ./install.sh . +RUN ls +RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0 From 8a48f5dd7174c3bbe36920ec8240eb59823c3605 Mon Sep 17 00:00:00 2001 From: Ismail D Date: Tue, 17 Aug 2021 17:59:34 +0200 Subject: [PATCH 144/207] Fix typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 285f147..7984a31 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Browse to http://localhost:3001 after started. If you want to change **port** and **volume**, or need to browse via a reserve proxy, please read wiki. -### 💪🏻 Without Docker (Recommanded for x86/x64 only) +### 💪🏻 Without Docker (Recommended for x86/x64 only) Required Tools: Node.js >= 14, git and pm2. From f72cdcc663ba7a909599dbe6e456a8b7142a554f Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Wed, 18 Aug 2021 11:40:20 +0800 Subject: [PATCH 145/207] Feat: Add time to beat tooltip, misc. fixes --- src/components/HeartbeatBar.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/HeartbeatBar.vue b/src/components/HeartbeatBar.vue index ddd1617..1f4ec1e 100644 --- a/src/components/HeartbeatBar.vue +++ b/src/components/HeartbeatBar.vue @@ -7,7 +7,7 @@ class="beat" :class="{ 'empty' : (beat === 0), 'down' : (beat.status === 0), 'pending' : (beat.status === 2) }" :style="beatStyle" - :title="beat.msg" + :title="getBeatTitle(beat)" />
@@ -21,7 +21,10 @@ export default { type: String, default: "big", }, - monitorId: Number, + monitorId: { + type: Number, + required: true, + }, }, data() { return { @@ -36,9 +39,6 @@ export default { computed: { beatList() { - if (! (this.monitorId in this.$root.heartbeatList)) { - this.$root.heartbeatList[this.monitorId] = []; - } return this.$root.heartbeatList[this.monitorId] }, @@ -113,6 +113,11 @@ export default { unmounted() { window.removeEventListener("resize", this.resize); }, + beforeMount() { + if (! (this.monitorId in this.$root.heartbeatList)) { + this.$root.heartbeatList[this.monitorId] = []; + } + }, mounted() { if (this.size === "small") { this.beatWidth = 5.6; @@ -129,6 +134,10 @@ export default { this.maxBeat = Math.floor(this.$refs.wrap.clientWidth / (this.beatWidth + this.beatMargin * 2)) } }, + + getBeatTitle(beat) { + return `${this.$root.datetime(beat.time)} - ${beat.msg}`; + } }, } From 269ac2410b2b586bacd8654ca972f4960ebab0f5 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Wed, 18 Aug 2021 14:55:03 +0800 Subject: [PATCH 146/207] install.sh add supports for CentOS --- extra/install.batsh | 93 ++++++++++++++++--- install.sh | 84 ++++++++++++++--- test/test_install_script/centos7.dockerfile | 5 - test/test_install_script/centos8.dockerfile | 4 + .../test_install_script/ubuntu1604.dockerfile | 4 + 5 files changed, 157 insertions(+), 33 deletions(-) create mode 100644 test/test_install_script/centos8.dockerfile create mode 100644 test/test_install_script/ubuntu1604.dockerfile diff --git a/extra/install.batsh b/extra/install.batsh index 005b2db..a89254f 100644 --- a/extra/install.batsh +++ b/extra/install.batsh @@ -1,9 +1,13 @@ +// install.sh is generated by ./extra/install.batsh, do not modify it directly. +// "npm run compile-install-script" to compile install.sh +// The command is working on Windows PowerShell and Docker for Windows only. println("====================="); println("Uptime Kuma Installer"); println("====================="); println(""); println("---------------------------------------"); println("This script is designed for Linux and basic usage."); +println("Tested with CentOS 7/8"); println("For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation"); println("---------------------------------------"); println(""); @@ -18,16 +22,19 @@ if ("$1" != "") { } if (type == "local") { - - if ("$1" != "") { - port = "$3"; - } else { - call("read", "-p", "Listening Port [3001]: ", "port"); - } + defaultPort = "3001"; + defaultInstallPath = "/opt/uptime-kuma"; if (exists("/etc/redhat-release")) { os = call("cat", "/etc/redhat-release"); distribution = "rhel"; + + } else if (exists("/etc/issue")) { + bash("os=$(head -n1 /etc/issue | cut -f 1 -d ' ')"); + if (os == "Ubuntu") { + distribution = "ubuntu"; + } + } bash("arch=$(uname -i)"); @@ -36,33 +43,89 @@ if (type == "local") { println("Distribution: " ++ distribution); println("Arch: " ++ arch); + if ("$3" != "") { + port = "$3"; + } else { + call("read", "-p", "Listening Port [$port]: ", "port"); + + if (port == "") { + port = defaultPort; + } + } + + if ("$2" != "") { + installPath = "$2"; + } else { + call("read", "-p", "Installation Path [$installPath]: ", "installPath"); + + if (installPath == "") { + installPath = defaultInstallPath; + } + } + if (distribution == "rhel") { - bash("nodePath=$(command -v node)"); + bash("nodeCheck=$(node -v)"); - if (nodePath != "") { + if (nodeCheck != "") { bash("nodeVersion=$(node -e 'console.log(process.versions.node.split(`.`)[0])')"); println("Node Version: " ++ nodeVersion); if (nodeVersion < "12") { println("Error: Required Node.js 14"); call("exit", "1"); - - } else { - if (nodeVersion == "12") { - println("Warning: NodeJS " ++ nodeVersion ++ " is not tested."); - } - println("OK"); } + if (nodeVersion == "12") { + println("Warning: NodeJS " ++ nodeVersion ++ " is not tested."); + } } else { + bash("curlCheck=$(curl --version)"); + if (curlCheck == "") { + println("Installing Curl"); + bash("yum -y -q install curl"); + } + + println("Installing Node.js 14"); + bash("curl -sL https://rpm.nodesource.com/setup_14.x | bash - > log.txt"); + bash("yum install -y -q nodejs"); + bash("node -v"); + + bash("nodeCheckAgain=$(node -v)"); + + if (nodeCheckAgain == "") { + println("Error during Node.js installation"); + bash("exit 1"); + } } + bash("check=$(git --version)"); + if (check == "") { + println("Installing Git"); + bash("yum -y -q install git"); + } + bash("check=$(pm2 --version)"); + if (check == "") { + println("Installing PM2"); + bash("npm install pm2 -g"); + bash("pm2 startup"); + } + + bash("mkdir -p $installPath"); + bash("cd $installPath"); + bash("git clone https://github.com/louislam/uptime-kuma.git ."); + bash("npm run setup"); - call("yum", "install", "git", "-y"); + bash("pm2 start npm --name uptime-kuma -- run start-server -- --port=$port"); + bash("pm2 list"); } + if (distribution == "ubuntu") { + println("TODO"); + // TODO + } + } else { call("read", "-p", "Expose Port [3001]: ", "port"); call("read", "-p", "Volume Name [uptime-kuma]: ", "volume"); diff --git a/install.sh b/install.sh index 8e9c828..2d4479a 100644 --- a/install.sh +++ b/install.sh @@ -1,50 +1,108 @@ +# install.sh is generated by ./extra/install.batsh, do not modify it directly. +# "npm run compile-install-script" to compile install.sh +# The command is working on Windows PowerShell and Docker for Windows only. "echo" "-e" "=====================" "echo" "-e" "Uptime Kuma Installer" "echo" "-e" "=====================" "echo" "-e" "" "echo" "-e" "---------------------------------------" "echo" "-e" "This script is designed for Linux and basic usage." +"echo" "-e" "Tested with CentOS 7/8" "echo" "-e" "For advanced usage, please go to https://github.com/louislam/uptime-kuma/wiki/Installation" "echo" "-e" "---------------------------------------" "echo" "-e" "" "echo" "-e" "Local - Install Uptime Kuma in your current machine with git, Node.js 14 and pm2" "echo" "-e" "Docker - Install Uptime Kuma Docker container" "echo" "-e" "" -"echo" "-e" "$1" if [ "$1" != "" ]; then type="$1" else "read" "-p" "Which installation method do you prefer? [DOCKER/local]: " "type" fi if [ "$type" == "local" ]; then - "read" "-p" "Listening Port [3001]: " "port" + defaultPort="3001" + defaultInstallPath="/opt/uptime-kuma" if [ -e "/etc/redhat-release" ]; then os=$("cat" "/etc/redhat-release") - distribution="rhel" + distribution="rhel" + else + if [ -e "/etc/issue" ]; then + os=$(head -n1 /etc/issue | cut -f 1 -d ' ') + if [ "$os" == "Ubuntu" ]; then + distribution="ubuntu" +fi fi + fi arch=$(uname -i) "echo" "-e" "Your OS: ""$os" "echo" "-e" "Distribution: ""$distribution" "echo" "-e" "Arch: ""$arch" + if [ "$3" != "" ]; then + port="$3" + else + "read" "-p" "Listening Port [$port]: " "port" + if [ "$port" == "" ]; then + port="$defaultPort" +fi + fi + if [ "$2" != "" ]; then + installPath="$2" + else + "read" "-p" "Installation Path [$installPath]: " "installPath" + if [ "$installPath" == "" ]; then + installPath="$defaultInstallPath" +fi + fi if [ "$distribution" == "rhel" ]; then - nodePath=$(command -v node) - if [ "$nodePath" != "" ]; then + nodeCheck=$(node -v) + if [ "$nodeCheck" != "" ]; then nodeVersion=$(node -e 'console.log(process.versions.node.split(`.`)[0])') "echo" "-e" "Node Version: ""$nodeVersion" _0="12" if [ $(($nodeVersion < $_0)) == 1 ]; then "echo" "-e" "Error: Required Node.js 14" - "exit" "1" - else - if [ "$nodeVersion" == "12" ]; then - "echo" "-e" "Warning: NodeJS ""$nodeVersion"" is not tested." + "exit" "1" +fi + if [ "$nodeVersion" == "12" ]; then + "echo" "-e" "Warning: NodeJS ""$nodeVersion"" is not tested." fi - "echo" "-e" "OK" - fi else -- + curlCheck=$(curl --version) + if [ "$curlCheck" == "" ]; then + "echo" "-e" "Installing Curl" + yum -y -q install curl +fi + "echo" "-e" "Installing Node.js 14" + curl -sL https://rpm.nodesource.com/setup_14.x | bash - > log.txt + yum install -y -q nodejs + node -v + nodeCheckAgain=$(node -v) + if [ "$nodeCheckAgain" == "" ]; then + "echo" "-e" "Error during Node.js installation" + exit 1 +fi fi - "yum" "install" "git" "-y" + check=$(git --version) + if [ "$check" == "" ]; then + "echo" "-e" "Installing Git" + yum -y -q install git +fi + check=$(pm2 --version) + if [ "$check" == "" ]; then + "echo" "-e" "Installing PM2" + npm install pm2 -g + pm2 startup +fi + mkdir -p $installPath + cd $installPath + git clone https://github.com/louislam/uptime-kuma.git . + npm run setup + pm2 start npm --name uptime-kuma -- run start-server -- --port=$port + pm2 list +fi + if [ "$distribution" == "ubuntu" ]; then + "echo" "-e" "TODO" + # TODO fi else "read" "-p" "Expose Port [3001]: " "port" diff --git a/test/test_install_script/centos7.dockerfile b/test/test_install_script/centos7.dockerfile index ef3ec5b..6e50b91 100644 --- a/test/test_install_script/centos7.dockerfile +++ b/test/test_install_script/centos7.dockerfile @@ -1,9 +1,4 @@ FROM centos:7 -RUN useradd -ms /bin/bash test_user -USER test_user -WORKDIR /home/test_user - COPY ./install.sh . -RUN ls RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0 diff --git a/test/test_install_script/centos8.dockerfile b/test/test_install_script/centos8.dockerfile new file mode 100644 index 0000000..7a121f7 --- /dev/null +++ b/test/test_install_script/centos8.dockerfile @@ -0,0 +1,4 @@ +FROM centos:8 + +COPY ./install.sh . +RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0 diff --git a/test/test_install_script/ubuntu1604.dockerfile b/test/test_install_script/ubuntu1604.dockerfile new file mode 100644 index 0000000..8cc6e14 --- /dev/null +++ b/test/test_install_script/ubuntu1604.dockerfile @@ -0,0 +1,4 @@ +FROM ubuntu:16.04 + +COPY ./install.sh . +RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0 From 60b0ee2959d911c721cafee0e8c9ce3be61e3a34 Mon Sep 17 00:00:00 2001 From: Carl Sander Date: Wed, 18 Aug 2021 08:38:05 +0000 Subject: [PATCH 147/207] added K8s-Deployment and edited README --- README.md | 4 +++ kubernetes/README.md | 27 ++++++++++++++++ kubernetes/kustomization.yml | 10 ++++++ kubernetes/uptime-kuma/deployment.yml | 34 +++++++++++++++++++++ kubernetes/uptime-kuma/ingressroute.yml | 39 ++++++++++++++++++++++++ kubernetes/uptime-kuma/kustomization.yml | 5 +++ kubernetes/uptime-kuma/pvc.yml | 10 ++++++ kubernetes/uptime-kuma/service.yml | 13 ++++++++ 8 files changed, 142 insertions(+) create mode 100644 kubernetes/README.md create mode 100644 kubernetes/kustomization.yml create mode 100644 kubernetes/uptime-kuma/deployment.yml create mode 100644 kubernetes/uptime-kuma/ingressroute.yml create mode 100644 kubernetes/uptime-kuma/kustomization.yml create mode 100644 kubernetes/uptime-kuma/pvc.yml create mode 100644 kubernetes/uptime-kuma/service.yml diff --git a/README.md b/README.md index 7984a31..8297067 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,10 @@ docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name upti Browse to http://localhost:3001 after started. +### ☸️ Kubernetes + +See more [here](kubernetes/README.md) + If you want to change **port** and **volume**, or need to browse via a reserve proxy, please read wiki. diff --git a/kubernetes/README.md b/kubernetes/README.md new file mode 100644 index 0000000..1f243b5 --- /dev/null +++ b/kubernetes/README.md @@ -0,0 +1,27 @@ +# Uptime-Kuma K8s Deployment +## How does it work? + +Kustomize is a tool which builds a complete deployment file for all config elements. +You can edit the files in the ```uptime-kuma``` folder except the ```kustomization.yml``` until you know what you're doing. + +It creates a certificate with the specified Issuer and creates the Ingress for the Uptime-Kuma ClusterIP-Service + +## What do i have to edit? +You have to edit the ```ingressroute.yml``` to your needs. +This ingressroute.yml is for the [nginx-ingress-controller](https://kubernetes.github.io/ingress-nginx/) in combination with the [cert-manager](https://cert-manager.io/). + +- host +- secrets and secret names +- (Cluster)Issuer (optional) +- the Version in the Deployment-File + - update: + - change to newer version and run the above commands, it will update the pods one after another + +## How To use: + +- install [kustomize](https://kubectl.docs.kubernetes.io/installation/kustomize/) +- Edit files mentioned above to your needs +- run ```kustomize build > apply.yml``` +- run ```kubectl apply -f apply.yml``` + +Now you should see some k8s magic and Uptime-Kuma should be available at the specified address. \ No newline at end of file diff --git a/kubernetes/kustomization.yml b/kubernetes/kustomization.yml new file mode 100644 index 0000000..0daf10f --- /dev/null +++ b/kubernetes/kustomization.yml @@ -0,0 +1,10 @@ +namespace: uptime-kuma +namePrefix: uptime-kuma- + +commonLabels: + app: uptime-kuma + +bases: + - uptime-kuma + + diff --git a/kubernetes/uptime-kuma/deployment.yml b/kubernetes/uptime-kuma/deployment.yml new file mode 100644 index 0000000..9ea1bdf --- /dev/null +++ b/kubernetes/uptime-kuma/deployment.yml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + component: uptime-kuma + name: uptime-kuma +spec: + selector: + matchLabels: + component: uptime-kuma + replicas: 3 + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + type: RollingUpdate + + template: + metadata: + labels: + component: uptime-kuma + spec: + containers: + - name: uptime-kuma + image: louislam/uptime-kuma:1.2.0 + ports: + - containerPort: 3001 + volumeMounts: + - mountPath: /app/data + name: uptime-kuma-storage + volumes: + - name: uptime-kuma-storage + persistentVolumeClaim: + claimName: uptime-kuma-pvc diff --git a/kubernetes/uptime-kuma/ingressroute.yml b/kubernetes/uptime-kuma/ingressroute.yml new file mode 100644 index 0000000..66ad6fb --- /dev/null +++ b/kubernetes/uptime-kuma/ingressroute.yml @@ -0,0 +1,39 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + kubernetes.io/ingress.class: nginx + cert-manager.io/cluster-issuer: letsencrypt-prod + nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" + nginx.ingress.kubernetes.io/server-snippets: | + location / { + proxy_set_header Upgrade $http_upgrade; + proxy_http_version 1.1; + proxy_set_header X-Forwarded-Host $http_host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $host; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Upgrade $http_upgrade; + proxy_cache_bypass $http_upgrade; + } + name: uptime-kuma-ingress +spec: + tls: + - hosts: + - monitor.cxde.link + secretName: monitor-cxde-link-tls + rules: + - host: monitor.cxde.link + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: uptime-kuma-uptime-kuma + port: + number: 3001 diff --git a/kubernetes/uptime-kuma/kustomization.yml b/kubernetes/uptime-kuma/kustomization.yml new file mode 100644 index 0000000..638a2ab --- /dev/null +++ b/kubernetes/uptime-kuma/kustomization.yml @@ -0,0 +1,5 @@ +resources: + - deployment.yml + - service.yml + - ingressroute.yml + - pvc.yml \ No newline at end of file diff --git a/kubernetes/uptime-kuma/pvc.yml b/kubernetes/uptime-kuma/pvc.yml new file mode 100644 index 0000000..c20e5d0 --- /dev/null +++ b/kubernetes/uptime-kuma/pvc.yml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: uptime-kuma-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 4Gi \ No newline at end of file diff --git a/kubernetes/uptime-kuma/service.yml b/kubernetes/uptime-kuma/service.yml new file mode 100644 index 0000000..67f50a3 --- /dev/null +++ b/kubernetes/uptime-kuma/service.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: uptime-kuma +spec: + selector: + component: uptime-kuma + type: ClusterIP + ports: + - name: http + port: 3001 + targetPort: 3001 + protocol: TCP From cf5168a4e6e13c14d2c8553077f285dadcee0320 Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Wed, 18 Aug 2021 12:21:16 +0800 Subject: [PATCH 148/207] Fix: Resize chart on screen breakpoints --- src/components/PingChart.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/PingChart.vue b/src/components/PingChart.vue index 596ca00..53a8379 100644 --- a/src/components/PingChart.vue +++ b/src/components/PingChart.vue @@ -1,5 +1,5 @@ + + diff --git a/src/pages/Dashboard.vue b/src/pages/Dashboard.vue index 5db7040..7070179 100644 --- a/src/pages/Dashboard.vue +++ b/src/pages/Dashboard.vue @@ -1,38 +1,13 @@