-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstaller.sh
executable file
·61 lines (56 loc) · 1.65 KB
/
installer.sh
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
#!/usr/bin/env bash
#
# shellcheck disable=SC2145
#
# Simple nitronD installer
#
# Copyright Identiter: GPL-3.0
# Copyright (C) 2022~2023 UsiFX <[email protected]>
#
# Ensures proper use
if ! [[ $(uname -s) =~ ^(Linux|GNU*)$ ]]; then
echo "ERROR: run nitronD Installer on Linux" >&2
exit 1
elif ! [[ -t 0 ]]; then
echo "ERROR: run nitronD Installer from a terminal" >&2
exit 1
elif [[ $(whoami) == root ]]; then
echo "ERROR: do not run nitronD Installer as root" >&2
exit 1
elif [[ ${BASH_SOURCE[0]} != "$0" ]]; then
echo "ERROR: nitronD Installer cannot be sourced" >&2
return 1
fi
# Shell options
set -e
shopt -s progcomp
shopt -u dirspell progcomp_alias
# Required variables
REPO="https://github.com/UsiFX/OpenNitroN.git"
TARGET_REPO="${HOME}/OpenNitroN-temp"
BRANCH="main"
BIN_DIR="${PREFIX/\/usr}/usr/bin"
INCLUDE_DIR="${PREFIX/\/usr}/usr/include"
REQUIRED_DEPS=(git dialog)
which "${REQUIRED_DEPS[@]}" >/dev/null || echo "please download following packages, '${REQUIRED_DEPS[@]}'"
case $1 in
install)
echo "downloading nitrond..."
git clone --depth=1 "$REPO" "$TARGET_REPO" -b "$BRANCH"
echo "installing nitrond..."
chmod 755 "${TARGET_REPO}"
chmod +x "${TARGET_REPO}/nitrond"
chmod +x "${TARGET_REPO}/nitronapi.sh"
sudo cp -f "${TARGET_REPO}/nitrond" "${BIN_DIR}/nitrond"
sudo cp -f "${TARGET_REPO}/nitronapi.sh" "${INCLUDE_DIR}/nitronapi.sh"
sudo chmod 755 "${BIN_DIR}/nitrond"
sudo chmod 755 "${INCLUDE_DIR}/nitronapi.sh"
;;
uninstall)
echo "uinstalling nitrond..."
sudo rm -f "$(which nitrond)"
sudo rm -f "$INCLUDE_DIR"/nitronapi.sh
echo "finished uninstallation!"
;;
*) echo "usage: installer.sh [install] [uninstall]" ;;
esac