-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.sh-dist
132 lines (100 loc) · 5.27 KB
/
config.sh-dist
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
123
124
125
126
127
128
129
130
131
132
#!/bin/dash
# shellcheck disable=SC2034 # Unused variables left for readability
#
# ---------------------------------------------------------------------
# Paths and settings you may want to change
# ---------------------------------------------------------------------
#
# OS related packet manager to detect if packages are available or
# needs to be installed. For more see `pre-install.sh`
PKG_MANAGER='dpkg';
PKG_MANAGER_OPTS='-s';
PACKAGES_REQUIRED=' git wget sqlite3 curl';
PACKAGES_OPTIONAL='apt-transport-https ca-certificates ssl-cert';
PACKAGES_STOP_ON_INCOMPLETE='Y'; # If required packages are missing: Stop script
# the user for this installation (eg. the 'git' user in/for: /home/git where gitea will be installed)
USER=git;
# the port where gitea should be available
PORT=3001;
PATH_HOME='/home/git'; # home of $USER
PATH_BACKUPS="$PATH_HOME/backups"; # path for backups
PATH_GITEA="$PATH_HOME/tea"; # gitea in /home/git/tea/
PATH_REPOSITORIES="$PATH_HOME/repositories";# repos in /home/git/repositories/
ACTION_ASKQUESTIONS='Y'; # Ask or just use the config defaults (Y|N)? N for automisations
# If 'N' all actions will perform without asking.
ACTION_TYPE='I'; # Type of installation: I|U
# I = Install (new installation) also possible for updates
# to detect OS changes
# U = just updates (fast, maybe dont work on OS changes)
ACTION_BACKUPDEFAULT='Y'; # default value for creating backups first: Y|N
# To install as a service set to 1 otherwise something different e.g: 0
INSTALL_AS_SERVICE=1;
# ---------------------------------------------------------------------
# internals NOT for your custom `config.sh`!
# ---------------------------------------------------------------------
# gitea download url as var GITEA_BIN_URL to be installed by the installer.
# optional use a generic value: "latest" to scan github.com api to download the
# latest version (not recommended: can become buggy, unusable)
CONFIG_GITEA_BIN_URL='latest';
# older examples
## CONFIG_GITEA_BIN_URL=https://dl.gitea.io/gitea/1.4.2/gitea-1.4.2-linux-amd64
## CONFIG_GITEA_BIN_URL=https://dl.gitea.io/gitea/1.12.3/gitea-1.12.3-linux-amd64
## CONFIG_GITEA_BIN_URL=https://github.com/go-gitea/gitea/releases/download/v1.12.3/gitea-1.12.3-linux-amd64
## CONFIG_GITEA_BIN_URL=https://dl.gitea.io/gitea/1.15.6/gitea-1.15.6-linux-amd64
## CONFIG_GITEA_BIN_URL=https://github.com/go-gitea/gitea/releases/download/v1.15.6/gitea-1.15.6-linux-amd64
# where this sources are located to fetch updates with selfupdate.sh (stable branch)
GITEA_INSTALLER_BASEURL='https://raw.githubusercontent.com/flobee/gitea-installer/stable';
DIRNAME_REPOSITORIES=$(basename "${PATH_REPOSITORIES}");
DIRNAME_GITEA=$(basename "${PATH_GITEA}");
TIMENOW=$(date +'%Y%m%d-%H%M%S');
# check if 'latest'
if [ "${CONFIG_GITEA_BIN_URL}" = "latest" ] && [ "$GITEA_BIN_URL" = "" ]; then
GITEA_VERSION=$(curl --silent "https://api.github.com/repos/go-gitea/gitea/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's|[v,]||g' )
# detect OS/kernel
#if [ -n "$(uname -a | grep i386)" ]; then
if uname -a | grep -q i368; then
GITEA_BIN_URL="https://dl.gitea.io/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-386";
fi
if uname -a | grep -q x86_64; then
GITEA_BIN_URL="https://dl.gitea.io/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-amd64";
fi
if uname -a | grep armv6l; then
GITEA_BIN_URL="https://dl.gitea.io/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-arm-6";
fi
if uname -a | grep armv7l; then
GITEA_BIN_URL="https://dl.gitea.io/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-arm-7";
fi
if uname -a | grep aarch64; then
GITEA_BIN_URL="https://dl.gitea.io/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-arm64";
fi
if [ "$GITEA_BIN_URL" = "" ] || [ "${GITEA_VERSION}" = "" ]; then
echo "Detections of the latest gitea version failed for your OS.";
if [ "${GITEA_VERSION}" = "" ]; then
echo
echo "The API query may failed to detect a version. Dont use too often."
echo "Give it a try later or use";
echo "# runner.sh 'URL TO YOUR VERSION'";
echo "for a manual installation and skip autodetection this way."
echo
else
echo "Please find it for you needs and report it.";
fi
exit 1;
else
GITEA_BIN_BASENAME=$(basename "$GITEA_BIN_URL");
if [ "${GITEA_BIN_BASENAME}" = "" ]; then
GITEA_BIN_BASENAME='gitea-bin';
export GITEA_BIN_URL;
export GITEA_BIN_BASENAME;
fi
fi
#echo "Download 'latest' verison: ${GITEA_VERSION}, ${GITEA_BIN_BASENAME}";
fi
# only root can do stuff
RUNNING_USERID=$(id -u);
if [ "${RUNNING_USERID}" != "0" ]; then
echo '+-------------------------------------------------------------+';
echo "| The root user is required (0, found id '${RUNNING_USERID}') |";
echo '+-------------------------------------------------------------+';
exit 1;
fi