-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·171 lines (142 loc) · 5.03 KB
/
install.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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/dash
#echo "File: $(readlink -f "$0")";
# ---------------------------------------------------------------------
# Paths/ settings you may want to change: see config.sh
# ---------------------------------------------------------------------
# ---------------------------------------------------------------------
# Basic includes for all scripts
# ---------------------------------------------------------------------
DIR_OF_FILE="$(dirname "$(readlink -f "$0")")";
. "${DIR_OF_FILE}"/shellFunctions.sh;
sourceConfigs "${DIR_OF_FILE}" "config.sh-dist" "config.sh" "$1";
# ---------------------------------------------------------------------
# pre-install to check if required packages are available
# sh "${DIR_OF_FILE}"/pre-install.sh
# if [ "$?" != 0 ]; then
# exit 1;
# fi
if ! sh "${DIR_OF_FILE}"/pre-install.sh; then
echo 'no';
fi
# Download gitea bin
if ! sh "${DIR_OF_FILE}"/download.sh "$1"; then
exit 1;
fi
echo '###';
echo '# install binary...';
INSTALL_NOW=0;
if [ "${ACTION_ASKQUESTIONS}" = "Y" ]; then
CONFIRMCOMMAND=${ACTION_ASKQUESTIONS};
echo "Install the downloaded version of gitea now? (defaut: '${ACTION_ASKQUESTIONS}')";
if confirmCommand "${ACTION_ASKQUESTIONS}" && [ "${CONFIRMCOMMAND}" = "Y" ]; then
INSTALL_NOW=1;
else
echo "Abort by user";
exit 1;
fi
fi
if [ "${ACTION_ASKQUESTIONS}" = "N" ]; then
INSTALL_NOW=1;
fi
if [ "${INSTALL_NOW}" != 1 ]; then
echo "Abort install process";
fi
adduser --system \
--shell /bin/bash \
--gecos 'Git Version Control' \
--group --disabled-password \
--home "${PATH_HOME}" \
"${USER}";
mkdir -p "$PATH_REPOSITORIES";
chown "${USER}":"${USER}" "$PATH_REPOSITORIES";
mkdir -p "${PATH_HOME}/.ssh";
chown "${USER}":"${USER}" "${PATH_HOME}/.ssh";
chmod 700 "${PATH_HOME}/.ssh";
touch "${PATH_HOME}/.ssh/authorized_keys";
chown "${USER}":"${USER}" "${PATH_HOME}/.ssh/authorized_keys";
chmod 600 "${PATH_HOME}/.ssh/authorized_keys";
mkdir -p "${PATH_GITEA}";
chown "${USER}":"${USER}" "${PATH_GITEA}";
mkdir -p "${PATH_GITEA}/custom/conf" "${PATH_GITEA}/data" "${PATH_GITEA}/indexers" "${PATH_GITEA}/public" "${PATH_GITEA}/log";
chown -R "${USER}":"${USER}" "${PATH_GITEA}/custom/" "${PATH_GITEA}/data" "${PATH_GITEA}/indexers" "${PATH_GITEA}/public" "${PATH_GITEA}/log"
echo '# install binary';
cp -f "/tmp/${GITEA_BIN_BASENAME}" "${PATH_GITEA}/gitea";
chmod +x "${PATH_GITEA}/gitea";
chown "${USER}":"${USER}" "${PATH_GITEA}/gitea";
#
# preparing init service script
#
cat >/etc/systemd/system/gitea.service <<EOTEXT
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
#After=mysqld.service
#After=postgresql.service
#After=memcached.service
#After=redis.service
[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
RestartSec=10s
Type=simple
User=${USER}
Group=${USER}
WorkingDirectory=${PATH_HOME}/tea
ExecStart=${PATH_GITEA}/gitea web -p $PORT -c ${PATH_GITEA}/custom/conf/app.ini
Restart=always
Environment=USER=${USER} HOME=${PATH_HOME} GITEA_WORK_DIR=${PATH_GITEA}
# If you want to bind Gitea to a port below 1024 uncomment
# the two values below
###
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
EOTEXT
echo '---------------------------------------------------------------------';
echo "You should be in as user '${USER}' now! verify with eg: $: id";
echo 'Copy the following infomations because after starting the gitea server';
echo 'it will output an lot and then execute now to start the gitea server: ';
echo " cd ${PATH_GITEA}";
echo " ./gitea web -p ${PORT} -c custom/conf/app.ini";
echo
echo "New install: Now open your browser to http://<server>:${PORT} and follow";
echo "the instructions";
echo
echo "If you just upgrade the binary: ";
echo "Make sure the conf/app.ini is writable for the user '${USER}' if you want";
echo "to change settings! Otherwise just go ahead, see below";
echo
echo 'Note: If you have an existing app.ini the values are NOT SHOWN';
echo 'It shows default values! Take care!';
echo
echo ' To help you a little (simple install):';
echo ' DB : sqlite';
echo " Path: ${PATH_GITEA}/data/gitea.db";
echo " Path repos: ${PATH_REPOSITORIES}";
echo " LFS: ${PATH_GITEA}/data/lfs ";
echo '';
echo ' Mail setup: Ask your admins!';
echo '---------------------------------------------------------------------';
echo "After it, close the session CRTL + C (stop gitea) then CRTL + D (out ";
echo "of user ${USER}) to go ahead with this script";
echo '---------------------------------------------------------------------';
# first run of gittea should be under user ${USER}
su - "${USER}"
if [ "$INSTALL_AS_SERVICE" = "1" ];
then
# remove existing
systemctl daemon-reload;
systemctl stop gitea;
systemctl disable gitea;
# re-add
systemctl enable gitea;
systemctl daemon-reload;
systemctl start gitea;
fi
. "${DIR_OF_FILE}"/z_after_install_update.sh;