Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neutrinet_cube_install
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
11
Issues
11
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Neutrinet
neutrinet_cube_install
Commits
7ac9d542
Commit
7ac9d542
authored
Feb 09, 2020
by
HgO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Issues with the cleanup function when aborting"
parent
20549222
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
365 additions
and
369 deletions
+365
-369
locale/fr/LC_MESSAGES/neutrinet.mo
locale/fr/LC_MESSAGES/neutrinet.mo
+0
-0
locale/fr/LC_MESSAGES/neutrinet.po
locale/fr/LC_MESSAGES/neutrinet.po
+166
-166
locale/neutrinet.pot
locale/neutrinet.pot
+163
-163
neutrinet_cube_install.sh
neutrinet_cube_install.sh
+36
-40
No files found.
locale/fr/LC_MESSAGES/neutrinet.mo
View file @
7ac9d542
No preview for this file type
locale/fr/LC_MESSAGES/neutrinet.po
View file @
7ac9d542
This diff is collapsed.
Click to expand it.
locale/neutrinet.pot
View file @
7ac9d542
This diff is collapsed.
Click to expand it.
neutrinet_cube_install.sh
View file @
7ac9d542
...
...
@@ -27,16 +27,19 @@
declare
-A
LOG_LEVELS
=([
DEBUG]
=
0
[
INFO]
=
1
[
WARN]
=
2
[
ERROR]
=
3
)
LOG_LEVEL
=
${
LOG_LEVELS
[INFO]
}
CURRENT_SCRIPT_LOCATION
=
"
$(
realpath
$(
dirname
$0
))
"
export
TEXTDOMAIN
=
"neutrinet"
export
TEXTDOMAINDIR
=
"
$
(
dirname
$0
)
/locale"
export
TEXTDOMAINDIR
=
"
$
CURRENT_SCRIPT_LOCATION
/locale"
CURRENT_SCRIPT_DIR
=
"
$(
dirname
$0
)
"
YNH_IMG_LOCATION
=
"https://build.yunohost.org"
DEBIAN_CODENAME
=
"stretch"
INTERNETCUBE_PREFIX
=
"internetcube"
YUNOHOST_PREFIX
=
"yunohost"
CUBE_RESOURCES_LOCATION
=
"cube_resources"
CUBE_RESOURCES_DIR
=
"cube_resources"
CUBE_RESOURCES_LOCATION
=
"
${
CURRENT_SCRIPT_LOCATION
}
/
$CUBE_RESOURCES_DIR
"
GPG_HOME_DIR
=
".gnupg"
GPG_YUNOHOST_KEY
=
"0x360AAF3259A3E6FF"
...
...
@@ -56,6 +59,7 @@ INSTALL_SD_SCRIPT_NAME="install-sd.sh"
INSTALL_SD_CUSTOM_SCRIPT_ENABLED
=
true
HYPERCUBE_FILE
=
"install.hypercube"
HYPERCUBE_LOCATION
=
"
${
CURRENT_SCRIPT_LOCATION
}
/
${
HYPERCUBE_FILE
}
"
CUSTOM_SCRIPT_NAME
=
"custom_neutrinet_specifics.sh"
CUSTOM_SCRIPT_PATH
=
"
${
CUBE_RESOURCES_LOCATION
}
/
$CUSTOM_SCRIPT_NAME
"
...
...
@@ -348,14 +352,16 @@ function check_sudo() {
}
function
download_install_sd_script
()
{
pushd
$CUBE_RESOURCES_LOCATION
>
/dev/null
info
$"Downloading
$INSTALL_SD_SCRIPT_NAME
script..."
cd
$CUBE_RESOURCES_LOCATION
curl
--show-error
--fail
--silent
--output
"
$INSTALL_SD_SCRIPT_NAME
"
"
$INSTALL_SD_SCRIPT_LOCATION
/
$INSTALL_SD_SCRIPT_NAME
"
check_integrity
"
$INSTALL_SD_SCRIPT_SHA256SUM
"
"
$INSTALL_SD_SCRIPT_NAME
"
chmod
u+x
"
$INSTALL_SD_SCRIPT_NAME
"
cd
..
popd
>
/dev/null
}
#=================================================
...
...
@@ -430,7 +436,7 @@ function check_custom_script() {
function
get_hypercube_setting
()
{
local
key
=
"
$1
"
local
value
=
$(
jq
-r
".
$key
"
"
$HYPERCUBE_
FILE
"
)
local
value
=
$(
jq
-r
".
$key
"
"
$HYPERCUBE_
LOCATION
"
)
if
[[
$key
=
~ pass
(
word|phrase
)
]]
then
...
...
@@ -513,7 +519,7 @@ function show_hypercube_settings() {
function
create_hypercube_file
()
{
debug
$"Checking if
$HYPERCUBE_FILE
already exists..."
if
[[
-f
$HYPERCUBE_
FILE
]]
if
[[
-f
$HYPERCUBE_
LOCATION
]]
then
info
$"Found
$HYPERCUBE_FILE
!"
show_hypercube_settings | column
-t
-s
':'
...
...
@@ -703,7 +709,7 @@ EOF
do
json_args+
=(
--arg
$json_arg
"
${
!json_arg
}
"
)
done
jq
"
${
json_args
[@]
}
"
"
$hypercube_template
"
>
"
$HYPERCUBE_
FILE
"
jq
"
${
json_args
[@]
}
"
"
$hypercube_template
"
>
"
$HYPERCUBE_
LOCATION
"
info
$"
$HYPERCUBE_FILE
created!"
}
...
...
@@ -724,13 +730,13 @@ function get_image() {
fi
done
mkdir
-p
"
$CUBE_RESOURCES_LOCATION
"
cd
"
$CUBE_RESOURCES_LOCATION
"
download_image
cd
..
}
function
download_image
()
{
mkdir
-p
"
$CUBE_RESOURCES_LOCATION
"
pushd
"
$CUBE_RESOURCES_LOCATION
"
>
/dev/null
debug
$"Finding latest Yunohost
$board
image..."
ynh_image_zip
=
"
$(
curl
--show-error
--fail
--silent
$YNH_IMG_LOCATION
\
...
...
@@ -780,13 +786,15 @@ function download_image() {
fi
debug
$"Building internetcube image..."
chmod
u+x
$CUBE_BUILD_SCRIPT_DIR
check_sudo
sudo
bash
$CUBE_BUILD_SCRIPT_NAME
"
$ynh_image
"
sudo chmod
u+x
$CUBE_BUILD_SCRIPT_NAME
"./
$CUBE_BUILD_SCRIPT_NAME
"
"
$ynh_image
"
rm
-rf
$CUBE_BUILD_SCRIPT_DIR
fi
info
$"We've got our internetcube image!"
popd
>
/dev/null
}
function
flash_sd_card
()
{
...
...
@@ -796,9 +804,7 @@ function flash_sd_card() {
download_install_sd_script
fi
create_custom_script
local
install_sd_options
=(
-y
"
$HYPERCUBE_FILE
"
-f
$CUBE_RESOURCES_LOCATION
/
$image
)
local
install_sd_options
=(
-y
"
$HYPERCUBE_FILE
"
-f
"
$CUBE_RESOURCES_LOCATION
/
$image
"
)
if
$INSTALL_SD_CUSTOM_SCRIPT_ENABLED
then
...
...
@@ -814,21 +820,7 @@ function flash_sd_card() {
install_sd_options+
=(
-d
)
fi
"./
$CUBE_RESOURCES_LOCATION
/
$INSTALL_SD_SCRIPT_NAME
"
"
${
install_sd_options
[@]
}
"
}
function
create_custom_script
()
{
cat
<<
"
EOF
" >
$CUSTOM_SCRIPT_PATH
#!/bin/bash
# Adding neutrinet specifics
main_domain=
$(
yunohost tools maindomain
--output
=
plain
)
yunohost app fetchlist -n neutrinet -u https://neutrinet.be/apps.json --debug
yunohost app fetchlist --debug
yunohost app install neutrinet --force --debug --args "domain=
${
main_domain
}
&path=/neutrinet"
EOF
"
$CUBE_RESOURCES_LOCATION
/
$INSTALL_SD_SCRIPT_NAME
"
"
${
install_sd_options
[@]
}
"
}
function
create_custom_script
()
{
...
...
@@ -880,7 +872,7 @@ function search_cube() {
keep_searching
=
true
while
$keep_searching
do
"
./
$CUBE_RESOURCES_LOCATION
/
$INSTALL_SD_SCRIPT_NAME
"
-l
||
true
"
$CUBE_RESOURCES_LOCATION
/
$INSTALL_SD_SCRIPT_NAME
"
-l
||
true
info
$"If we found it you should be able to follow the progress at the HyperCube Debug url"
if
!
confirm
$"Do you want to continue searching?"
"y"
...
...
@@ -895,7 +887,7 @@ function search_cube() {
function
cleanup_hypercube_file
()
{
local
default_answer
=
$1
if
[[
!
-e
$HYPERCUBE_
FILE
]]
if
[[
!
-e
$HYPERCUBE_
LOCATION
]]
then
return
fi
...
...
@@ -908,7 +900,7 @@ function cleanup_hypercube_file() {
if
confirm
$"Do you want to remove the
$HYPERCUBE_FILE
file?"
$default_answer
then
info
$"Removing
$HYPERCUBE_FILE
..."
rm
-f
"
$HYPERCUBE_
FILE
"
rm
-f
"
$HYPERCUBE_
LOCATION
"
fi
}
...
...
@@ -921,10 +913,10 @@ function cleanup_cube_resources() {
fi
echo
info
$"We stored some resources (Yunohost images, scripts, etc.) in the
$CUBE_RESOURCES_
LOCATION
folder"
info
$"We stored some resources (Yunohost images, scripts, etc.) in the
$CUBE_RESOURCES_
DIR
folder"
info
$"These resources could be reused for another cube install, so you wouldn't need to download everything again"
if
confirm
$"Do you want to remove the
$CUBE_RESOURCES_
LOCATION
folder?"
$default_answer
if
confirm
$"Do you want to remove the
$CUBE_RESOURCES_
DIR
folder?"
$default_answer
then
info
$"Removing cube resources..."
rm
-rf
"
$CUBE_RESOURCES_LOCATION
"
...
...
@@ -943,6 +935,11 @@ function cleanup_resources_on_abort() {
# In case we want to exit the trap function with CTRL+C
trap
- ERR INT
# Clear terminal state in order to display user inputs
# This is needed when user input was previously hidden (e.g. prompt for password, etc.)
# See https://unix.stackexchange.com/questions/499471/reset-terminal-after-interrupting-read-r-s
stty
sane
echo
error
$"Installation aborted"
...
...
@@ -985,9 +982,7 @@ function show_help() {
}
function
prepare
()
{
info
$"Setting up the
$CUBE_RESOURCES_LOCATION
folder..."
mkdir
-p
"
$CUBE_RESOURCES_LOCATION
"
cd
$CUBE_RESOURCES_LOCATION
info
$"Setting up the
$CUBE_RESOURCES_DIR
folder..."
for
board
in
lime lime2
do
...
...
@@ -995,7 +990,6 @@ function prepare() {
download_image
done
cd
..
download_install_sd_script
}
...
...
@@ -1027,6 +1021,8 @@ done
# SCRIPT
#=================================================
set
-E
# Cleanup if any of the following command fails or if we do Ctrl+C
trap
"cleanup_resources_on_abort"
ERR INT
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment