Skip to content

Commit f92ec05

Browse files
author
Hunter T
committed
Update code examples
1 parent 52c1d23 commit f92ec05

File tree

2 files changed

+85
-67
lines changed

2 files changed

+85
-67
lines changed

Examples/example-1.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,31 @@ installer_repo="StrangeRanger/NadekoBot-BashScript"
4343
# The branch of $installer_repo that the installer will download its scripts from.
4444
#
4545
# Options:
46-
# master = Production ready code (the latest stable code)
47-
# dev = Non-production ready code (has the possibility of breaking something)
46+
# main = Production ready code (the latest stable code)
47+
# NadekoV3 = The version of the installer designed for NadekoBot v3
48+
# dev = Non-production ready code (has the possibility of breaking something)
4849
#
49-
# Default: "master"
50-
installer_branch="master"
50+
# Default: "main"
51+
installer_branch="main"
5152

5253
# The branch/tag, of NadekoBot's official repo, that the installer will download the bot
5354
# from.
5455
#
5556
# IMPORTANT: Using a branch/tag containing code older than the one currently on your
5657
# system, increases the likelihood of failed builds due to incompatible
5758
# changes in the code/files coppied from the current to the newly downloaded
58-
# version.
59+
# version. For this, and other reasons, it's generally not recommended to
60+
# to modify $_NADEKO_INSTALL_VERSION. This is especially true when it comes
61+
# to a difference of major version changes, such as v3 and v4.
5962
#
6063
# Options:
61-
# v3 = Latest version (the master/main branch)
64+
# v4 = Latest version (the master/main branch)
65+
# v3 = NadekoBot v3
6266
# x.x.x = Any other branch/tag (refer to the NadekoBot repo for available tags and
6367
# branches)
6468
#
65-
# Default: "v3"
66-
export _NADEKO_INSTALL_VERSION="v3"
69+
# Default: "v4"
70+
export _NADEKO_INSTALL_VERSION="v4"
6771

6872
# A list of files to be backed up when executing option 7.
6973
#
@@ -77,24 +81,26 @@ export _NADEKO_INSTALL_VERSION="v3"
7781
# - Valid: "nadekobot/output/creds.yml nadekobot/output/data/bot.yml"
7882
# - Invalid: "nadekobot/output/creds.yml, nadekobot/output/data/bot.yml"
7983
# - Invalid: "nadekobot/output/creds.yml,nadekobot/output/data/bot.yml"
80-
# 3. Both the file nor the path to the file can contain a space.
84+
# 3. Niether the file nor the path to the file can contain a space.
8185
# - Valid: 'nadekobot/output/data/NadekoBot.db'
8286
# - Invalid: 'nadeko bot/output/data/NadekoBot.db'
8387
#
8488
# Default: "nadekobot/output/creds.yml
89+
# nadekobot/output/data/NadekoBot.db
90+
# nadekobot/output/data/bot.yml
8591
# nadekobot/output/data/gambling.yml
92+
# nadekobot/output/data/games.yml
93+
# nadekobot/output/data/images.yml
8694
# nadekobot/output/data/xp.yml
87-
# nadekobot/output/data/images.json
88-
# nadekobot/output/data/xp_template.json
89-
# nadekobot/output/data/bot.yml
90-
# nadekobot/output/data/NadekoBot.db"
95+
# nadekobot/output/data/xp_template.json"
9196
export _FILES_TO_BACK_UP="nadekobot/output/creds.yml
97+
nadekobot/output/data/NadekoBot.db
98+
nadekobot/output/data/bot.yml
9299
nadekobot/output/data/gambling.yml
100+
nadekobot/output/data/games.yml
101+
nadekobot/output/data/images.yml
93102
nadekobot/output/data/xp.yml
94-
nadekobot/output/data/images.json
95-
nadekobot/output/data/xp_template.json
96-
nadekobot/output/data/bot.yml
97-
nadekobot/output/data/NadekoBot.db"
103+
nadekobot/output/data/xp_template.json"
98104

99105

100106
#### End of [[ Configuration Variables ]]
@@ -104,7 +110,7 @@ nadekobot/output/data/NadekoBot.db"
104110

105111
# Revision number of this script.
106112
# Refer to the 'README' note at the beginning of this file for more information.
107-
export _LINUXAIO_REVISION="30"
113+
export _LINUXAIO_REVISION="34"
108114
# The URL to the raw code of a script that is specified by the other scripts.
109115
export _RAW_URL="https://raw.githubusercontent.com/$installer_repo/$installer_branch"
110116

@@ -119,8 +125,6 @@ export _RAW_URL="https://raw.githubusercontent.com/$installer_repo/$installer_br
119125

120126
echo "Downloading the latest installer..."
121127
curl -O "$_RAW_URL"/installer_prep.sh
122-
# NOTE: The meaning of the exit codes passed by 'installer_prep.sh' can be found here:
123-
# TODO: Add a link to the error code meaning at the wiki
124128
sudo chmod +x installer_prep.sh \
125129
&& ./installer_prep.sh \
126130
|| exit "$?" # Uses the exit code passed by 'installer_prep.sh'.

Examples/example-2.md

Lines changed: 61 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ The code below is from an installer project that can be refered to at this link:
1919

2020
# Revision number of 'linuxAIO.sh'.
2121
# Refer to the 'README' note at the beginning of 'linuxAIO.sh' for more information.
22-
current_linuxAIO_revision="30"
22+
current_linuxAIO_revision="34"
2323
# Name of the master installer script.
24-
master_installer="nadeko_master_installer.sh"
24+
master_installer="nadeko_main_installer.sh"
2525

2626
## Modify output text color.
2727
export _YELLOW=$'\033[1;33m'
@@ -48,6 +48,7 @@ export _CLRLN=$'\r\033[K'
4848
#### [ Functions ]
4949

5050

51+
# shellcheck disable=SC1091
5152
detect_sys_info() {
5253
####
5354
# Function Info: Identify the operating system, version number, architecture, bit
@@ -82,38 +83,53 @@ linuxAIO_update() {
8283
# and $current_linuxAIO_revision aren't of equal value.
8384
####
8485

85-
## Save the values of the current Configuration Variables specified in
86-
## 'linuxAIO.sh', to be set in the new 'linuxAIO.sh'.
87-
## NOTE: Declaration and instantiation is separated at the recommendation by
88-
## shellcheck.
89-
local installer_branch # A.1.
90-
local installer_branch_found # A.1.
91-
installer_branch=$(grep '^installer_branch=.*' linuxAIO.sh) # A.1.
92-
installer_branch_found="$?" # A.1.
93-
local nadeko_install_version # A.2.
94-
local nadeko_install_version_found # A.2.
95-
nadeko_install_version=$(grep '^export _NADEKO_INSTALL_VERSION=.*' linuxAIO.sh) # A.2.
96-
nadeko_install_version_found="$?" # A.2.
97-
9886
echo "${_YELLOW}You are using an older version of 'linuxAIO.sh'$_NC"
9987
echo "Downloading latest 'linuxAIO.sh'..."
100-
curl -O "$_RAW_URL"/linuxAIO.sh \
101-
&& sudo chmod +x linuxAIO.sh
10288

103-
echo "Applying existing configurations to the new 'linuxAIO.sh'..."
89+
## Only download the newest version of 'linuxAIO.sh'.
90+
## Reason: Starting with revision 31, the default version of NadekoBot is v4. To
91+
## ensure there are not errors cropping up due to incompatible installer
92+
## and NadekoBot version, all variables in 'linuxAIO.sh' are reset to their
93+
## [new] defaults.
94+
if ((_LINUXAIO_REVISION <= 30)); then
95+
curl -O "$_RAW_URL"/linuxAIO.sh \
96+
&& sudo chmod +x linuxAIO.sh
97+
echo "${_CYAN}NOT applying existing configurations to the new 'linuxAIO.sh'..."
98+
echo "${_GREEN}Successfully downloaded the newest version of 'linuxAIO.sh'.$_NC"
99+
## Download the newest version of 'linuxAIO.sh' and apply existing changes to it.
100+
else
101+
## Save the values of the current Configuration Variables specified in
102+
## 'linuxAIO.sh', to be set in the new 'linuxAIO.sh'.
103+
## NOTE: Declaration and instantiation is separated at the recommendation by
104+
## shellcheck.
105+
local installer_branch # A.1.
106+
local installer_branch_found # A.1.
107+
installer_branch=$(grep '^installer_branch=.*' linuxAIO.sh) # A.1.
108+
installer_branch_found="$?" # A.1.
109+
local nadeko_install_version # A.2.
110+
local nadeko_install_version_found # A.2.
111+
nadeko_install_version=$(grep '^export _NADEKO_INSTALL_VERSION=.*' linuxAIO.sh) # A.2.
112+
nadeko_install_version_found="$?" # A.2.
113+
114+
curl -O "$_RAW_URL"/linuxAIO.sh \
115+
&& sudo chmod +x linuxAIO.sh
116+
117+
echo "Applying existing configurations to the new 'linuxAIO.sh'..."
118+
119+
## Set $installer_branch inside of the new 'linuxAIO.sh'.
120+
if [[ $installer_branch_found = 0 ]]; then
121+
sed -i "s/^installer_branch=.*/$installer_branch/" linuxAIO.sh
122+
fi
104123

105-
## Set $installer_branch inside of the new 'linuxAIO.sh'.
106-
if [[ $installer_branch_found = 0 ]]; then
107-
sed -i "s/^installer_branch=.*/$installer_branch/" linuxAIO.sh
108-
fi
124+
## Set $nadeko_install_version inside of the new 'linuxAIO.sh'.
125+
if [[ $nadeko_install_version_found = 0 ]]; then
126+
sed -i "s/^export _NADEKO_INSTALL_VERSION=.*/$nadeko_install_version/" linuxAIO.sh
127+
fi
109128

110-
## Set $nadeko_install_version inside of the new 'linuxAIO.sh'.
111-
if [[ $nadeko_install_version_found = 0 ]]; then
112-
sed -i "s/^export _NADEKO_INSTALL_VERSION=.*/$nadeko_install_version/" linuxAIO.sh
129+
echo "${_GREEN}Successfully downloaded the newest version of 'linuxAIO.sh'" \
130+
"and applied changes to the newest version of 'linuxAIO.sh'$_NC"
113131
fi
114132

115-
echo "${_GREEN}Successfully downloaded the newest version of 'linuxAIO.sh' and" \
116-
"applied changes to the newest version of 'linuxAIO.sh'$_NC"
117133
clean_up "0" "Exiting" "true"
118134
}
119135

@@ -149,9 +165,8 @@ clean_up() {
149165
####
150166

151167
# Files to be removed.
152-
local installer_files=("credentials_setup.sh" "installer_prep.sh"
153-
"prereqs_installer.sh" "nadeko_latest_installer.sh" "nadeko_runner.sh"
154-
"nadeko_master_installer.sh" "file_backup.sh")
168+
local installer_files=("installer_prep.sh" "file_backup.sh" "prereqs_installer.sh"
169+
"nadeko_latest_installer.sh" "nadeko_runner.sh" "nadeko_main_installer.sh")
155170

156171
if [[ $3 = true ]]; then echo "Cleaning up..."
157172
else echo -e "\nCleaning up..."
@@ -185,23 +200,22 @@ execute_master_installer() {
185200
####
186201

187202
_DOWNLOAD_SCRIPT "$master_installer" "true"
188-
./nadeko_master_installer.sh
203+
./nadeko_main_installer.sh
189204
clean_up "$?" "Exiting"
190205
}
191206

192207
########################################################################################
193208
#### [[ Functions To Be Exported ]]
194209

195210

196-
# TODO: Add explanation to $2...
197211
_DOWNLOAD_SCRIPT() {
198212
####
199213
# Function Info: Download the specified script and modify it's execution
200214
# permissions.
201215
#
202216
# Parameters:
203217
# $1 - Name of script to download.
204-
# $2 - ...
218+
# $2 - True if the script shouldn't output text indicating $1 is being downloaded.
205219
####
206220

207221
if [[ ! $2 ]]; then echo "Downloading '$1'..."
@@ -221,8 +235,7 @@ _DOWNLOAD_SCRIPT() {
221235

222236
# Execute when the user uses 'Ctrl + Z', 'Ctrl + C', or otherwise forcefully exits the
223237
# installer.
224-
trap 'echo -e "\n\nScript forcefully stopped"
225-
clean_up "2" "Exiting" "true"' \
238+
trap 'clean_up "2" "Exiting" "true"' \
226239
SIGINT SIGTSTP SIGTERM
227240

228241

@@ -254,7 +267,7 @@ export _INSTALLER_PREP="$_WORKING_DIR/installer_prep.sh"
254267
#### [ Main ]
255268

256269

257-
clear -x # Clear the screen of any text.
270+
clear -x
258271

259272
detect_sys_info
260273
export _DISTRO _SVER _VER _ARCH
@@ -271,30 +284,31 @@ Distro Version: $_VER
271284
### Check if the operating system is supported by NadekoBot and installer.
272285
if [[ $bits = 64 ]]; then
273286
# Ubuntu:
274-
# 16.04
275-
# 18.04
287+
# 22.04
276288
# 20.04
289+
# 18.04
290+
# 16.04
277291
if [[ $_DISTRO = "ubuntu" ]]; then
278292
case "$_VER" in
279-
16.04|18.04|20.04) execute_master_installer ;;
280-
*) unsupported ;;
293+
16.04|18.04|20.04|22.04) execute_master_installer ;;
294+
*) unsupported ;;
281295
esac
282296
# Debian:
283-
# 9
297+
# 11
284298
# 10
299+
# 9
285300
elif [[ $_DISTRO = "debian" ]]; then
286301
case "$_SVER" in
287-
9|10) execute_master_installer ;;
288-
*) unsupported ;;
302+
9|10|11) execute_master_installer ;;
303+
*) unsupported ;;
289304
esac
290305
# Linux Mint:
291-
# 18
292-
# 19
293306
# 20
307+
# 19
294308
elif [[ $_DISTRO = "linuxmint" ]]; then
295309
case "$_SVER" in
296-
18|19|20) execute_master_installer ;;
297-
*) unsupported ;;
310+
19|20) execute_master_installer ;;
311+
*) unsupported ;;
298312
esac
299313
else
300314
unsupported

0 commit comments

Comments
 (0)