This repository was archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathservice-install.sh
More file actions
executable file
·78 lines (68 loc) · 2.27 KB
/
service-install.sh
File metadata and controls
executable file
·78 lines (68 loc) · 2.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
#!/bin/bash
echo "================================================================================"
echo "This installation script will register a system service. When finished, the name"
echo "of this service is readable by any user. To make sure that it cannot be used for"
echo "detection purposes, you have to enter a random service name. Ensure that it does"
echo "not exist already, and only use characters in [0-9A-Z-]."
echo "================================================================================"
echo "Additionally, please refer to https://github.com/XRadius/http-driver#warnings"
echo "before continuing to understand the security implications of this tool."
echo "================================================================================"
read -p "ServiceName: " serviceName
# ====================
#
# ====================
if grep Password ./src/appsettings.json | sed -r 's/^[^:]*:(.*)$/\1/' | grep -q guest;
then
echo ""
echo "Default password used. This is not safe!"
echo "See: https://github.com/XRadius/http-driver#warnings for more information."
read -p "Continue? [y/N]: " continueInstall
if [[ ! "$continueInstall" =~ ^([yY][eE][sS]|[yY])$ ]];
then echo "Please change the password. Exiting..." && exit 3;
fi;
fi
# ====================
#
# ====================
rootPath="/root/.${serviceName}"
execPath="/root/.${serviceName}/${serviceName}"
servPath="/etc/systemd/system/${serviceName}.service"
# ====================
#
# ====================
rm -rf "bin"
rm -rf "$rootPath"
# ====================
#
# ====================
dotnet publish src --output "${rootPath}" --runtime linux-x64 --self-contained \
"-p:Configuration=Release" \
"-p:AssemblyName=${serviceName}" \
"-p:DebugType=None" \
"-p:GenerateRuntimeConfigurationFiles=true" \
"-p:PublishSingleFile=true"
# ====================
#
# ====================
cat > $servPath << EOF
[Unit]
Description=${serviceName}
[Service]
Type=notify
WorkingDirectory=${rootPath}
ExecStart=${execPath}
Environment=ASPNETCORE_URLS=http://*:8080/
[Install]
WantedBy=multi-user.target
EOF
# ====================
#
# ====================
chmod 770 "$servPath"
# ====================
#
# ====================
systemctl daemon-reload
systemctl start "${serviceName}"
systemctl enable "${serviceName}"