-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinstall-service.sh
More file actions
122 lines (105 loc) · 3.27 KB
/
Copy pathinstall-service.sh
File metadata and controls
122 lines (105 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
# AxonASP Service Installation Script
#
# AxonASP Server
# Copyright (C) 2026 G3pix Ltda. All rights reserved.
#
# Developed by Lucas Guimarães - G3pix Ltda
# Contact: https://g3pix.com.br
# Project URL: https://g3pix.com.br/axonasp
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# Attribution Notice:
# If this software is used in other projects, the name "AxonASP Server"
# must be cited in the documentation or "About" section.
#
# Contribution Policy:
# Modifications to the core source code of AxonASP Server must be
# made available under this same license terms.
#
# --- Script Configuration ---
SERVICE_EXECUTABLE="./axonasp-service"
SERVICE_NAME="axonasp"
# --- Color Codes for Output ---
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# --- Function to display error message ---
write_error() {
echo -e "${RED}ERROR: $1${NC}"
}
# --- Function to display success message ---
write_success() {
echo -e "${GREEN}SUCCESS: $1${NC}"
}
# --- Function to display info message ---
write_info() {
echo -e "${CYAN}INFO: $1${NC}"
}
# --- Function to check if running as root ---
check_root() {
if [[ $EUID -ne 0 ]]; then
write_error "This script must be run as root (use sudo)."
write_info "Please try again with: sudo ./install-service.sh"
exit 1
fi
}
# --- Function to check if systemd is available ---
check_systemd() {
if ! command -v systemctl &> /dev/null; then
write_error "systemd is not available on this system."
write_info "This script requires systemd for service management."
exit 1
fi
}
# --- Main Script Execution ---
write_info "Starting AxonASP Service Installation..."
# Check if running as root
check_root
# Check if systemd is available
check_systemd
# Check if the service executable exists
if [[ ! -f $SERVICE_EXECUTABLE ]]; then
write_error "Service executable not found at: $SERVICE_EXECUTABLE"
write_info "Please ensure axonasp-service is in the current directory."
exit 1
fi
# Make the service executable if not already
if [[ ! -x $SERVICE_EXECUTABLE ]]; then
write_info "Making service executable..."
chmod +x "$SERVICE_EXECUTABLE"
fi
# Install the service
write_info "Installing AxonASP Service..."
"$SERVICE_EXECUTABLE" install
if [[ $? -eq 0 ]]; then
write_success "Service installed successfully."
else
write_error "Failed to install service."
exit 1
fi
# Start the service
write_info "Starting AxonASP Service..."
"$SERVICE_EXECUTABLE" start
if [[ $? -eq 0 ]]; then
write_success "Service started successfully."
else
write_error "Failed to start service."
exit 1
fi
# Check service status using systemctl
write_info "Checking service status..."
if systemctl is-active --quiet "$SERVICE_NAME"; then
write_success "AxonASP Service is running and ready to use."
write_info "Service Status: $(systemctl is-active $SERVICE_NAME)"
else
write_error "Service failed to start or is not running."
write_info "Current Status: $(systemctl is-active $SERVICE_NAME)"
exit 1
fi
write_success "AxonASP Service installation completed successfully!"
exit 0