File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Dependency: requires jq (https://stedolan.github.io/jq/)
4
+ # Install via Homebrew: `brew install jq`
5
+
6
+ # Required parameters:
7
+ # @raycast.schemaVersion 1
8
+ # @raycast.title Is It Up?
9
+ # @raycast.mode compact
10
+ # @raycast.packageName Developer Utils
11
+ #
12
+ # Optional parameters:
13
+ # @raycast.icon 🩺
14
+ # @raycast.argument1 { "type": "text", "placeholder": "Website" }
15
+ #
16
+ # Documentation:
17
+ # @raycast.description Check if a website is up
18
+ # @raycast.author Jesse Claven
19
+ # @raycast.authorURL https://github.com/jesse-c
20
+
21
+ if ! command -v jq & > /dev/null; then
22
+ echo " jq is required (https://stedolan.github.io/jq/)." ;
23
+ exit 1;
24
+ fi
25
+
26
+ status_code=$( curl --silent " https://isitup.org/$1 .json" | jq ' .status_code' )
27
+
28
+ # Sample output:
29
+ #
30
+ # {
31
+ # "domain": "duckduckgo.com",
32
+ # "port": 80,
33
+ # "status_code": 1,
34
+ # "response_ip": "52.142.124.215",
35
+ # "response_code": 200,
36
+ # "response_time": 0.021
37
+ # }
38
+
39
+ case $status_code in
40
+ 1) echo " Up: $1 "
41
+ exit 0
42
+ ;;
43
+ 2) echo " Down: $1 "
44
+ exit 0
45
+ ;;
46
+ 3) echo " Invalid domain: $1 "
47
+ exit 1
48
+ ;;
49
+ * ) echo " Unknown status code ($status_code ): $1 "
50
+ exit 1
51
+ ;;
52
+ esac
You can’t perform that action at this time.
0 commit comments