Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
6c143c31
Commit
6c143c31
authored
8 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
Comments
parent
16a43442
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/freedombone-utils-selector
+22
-6
22 additions, 6 deletions
src/freedombone-utils-selector
with
22 additions
and
6 deletions
src/freedombone-utils-selector
+
22
−
6
View file @
6c143c31
...
@@ -43,6 +43,7 @@ APPS_INSTALLED_NAMES=()
...
@@ -43,6 +43,7 @@ APPS_INSTALLED_NAMES=()
# file containing a list of removed apps
# file containing a list of removed apps
REMOVED_APPS_FILE
=
/root/removed
REMOVED_APPS_FILE
=
/root/removed
# gets the variants list from an app script
function
app_variants
{
function
app_variants
{
filename
=
$1
filename
=
$1
variants_line
=
$(
cat
${
filename
}
|
grep
"VARIANTS="
)
variants_line
=
$(
cat
${
filename
}
|
grep
"VARIANTS="
)
...
@@ -54,12 +55,14 @@ function app_variants {
...
@@ -54,12 +55,14 @@ function app_variants {
echo
"
$variants_list
"
echo
"
$variants_list
"
}
}
# whether a given item is in an array
function
item_in_array
{
function
item_in_array
{
local
e
local
e
for
e
in
"
${
@
:2
}
"
;
do
[[
"
$e
"
==
"
$1
"
]]
&&
return
0
;
done
for
e
in
"
${
@
:2
}
"
;
do
[[
"
$e
"
==
"
$1
"
]]
&&
return
0
;
done
return
1
return
1
}
}
# mark a given app as having been removed so that it doesn't get reinstalled on updates
function
remove_app
{
function
remove_app
{
app_name
=
$1
app_name
=
$1
if
[
!
-f
$REMOVED_APPS_FILE
]
;
then
if
[
!
-f
$REMOVED_APPS_FILE
]
;
then
...
@@ -70,6 +73,7 @@ function remove_app {
...
@@ -70,6 +73,7 @@ function remove_app {
fi
fi
}
}
# returns 1 if an app has been marked as removed
function
app_is_removed
{
function
app_is_removed
{
app_name
=
"
$1
"
app_name
=
"
$1
"
if
[
!
-f
$REMOVED_APPS_FILE
]
;
then
if
[
!
-f
$REMOVED_APPS_FILE
]
;
then
...
@@ -84,6 +88,7 @@ function app_is_removed {
...
@@ -84,6 +88,7 @@ function app_is_removed {
fi
fi
}
}
# Allows an app to be reinstalled even if it was previously marked as being removed
function
reinstall_app
{
function
reinstall_app
{
app_name
=
$1
app_name
=
$1
if
[
!
-f
$REMOVED_APPS_FILE
]
;
then
if
[
!
-f
$REMOVED_APPS_FILE
]
;
then
...
@@ -94,6 +99,7 @@ function reinstall_app {
...
@@ -94,6 +99,7 @@ function reinstall_app {
fi
fi
}
}
# returns 1 if an app is installed
function
app_is_installed
{
function
app_is_installed
{
app_name
=
"
$1
"
app_name
=
"
$1
"
...
@@ -109,6 +115,7 @@ function app_is_installed {
...
@@ -109,6 +115,7 @@ function app_is_installed {
return
return
fi
fi
# check the completion file to see if it was installed
if
[
!
-f
$COMPLETION_FILE
]
;
then
if
[
!
-f
$COMPLETION_FILE
]
;
then
echo
"0"
echo
"0"
return
return
...
@@ -121,6 +128,7 @@ function app_is_installed {
...
@@ -121,6 +128,7 @@ function app_is_installed {
fi
fi
}
}
# called at the end of the install section of an app script
function
install_completed
{
function
install_completed
{
if
[
!
${
1
}
]
;
then
if
[
!
${
1
}
]
;
then
exit
673935
exit
673935
...
@@ -128,6 +136,7 @@ function install_completed {
...
@@ -128,6 +136,7 @@ function install_completed {
echo
"install_
${
1
}
"
>>
$COMPLETION_FILE
echo
"install_
${
1
}
"
>>
$COMPLETION_FILE
}
}
# populates an array of "0" or "1" for whether apps are installed
function
get_apps_installed
{
function
get_apps_installed
{
for
a
in
"
${
APPS_AVAILABLE
[@]
}
"
for
a
in
"
${
APPS_AVAILABLE
[@]
}
"
do
do
...
@@ -135,6 +144,7 @@ function get_apps_installed {
...
@@ -135,6 +144,7 @@ function get_apps_installed {
done
done
}
}
# populates an array of installed app names
function
get_apps_installed_names
{
function
get_apps_installed_names
{
APPS_INSTALLED_NAMES
=()
APPS_INSTALLED_NAMES
=()
for
a
in
"
${
APPS_AVAILABLE
[@]
}
"
for
a
in
"
${
APPS_AVAILABLE
[@]
}
"
...
@@ -145,6 +155,7 @@ function get_apps_installed_names {
...
@@ -145,6 +155,7 @@ function get_apps_installed_names {
done
done
}
}
# detects what apps are available
function
detect_apps
{
function
detect_apps
{
FILES
=
/usr/share/
${
PROJECT_NAME
}
/apps/
${
PROJECT_NAME
}
-app-
*
FILES
=
/usr/share/
${
PROJECT_NAME
}
/apps/
${
PROJECT_NAME
}
-app-
*
...
@@ -166,6 +177,9 @@ function detect_apps {
...
@@ -166,6 +177,9 @@ function detect_apps {
get_apps_installed_names
get_apps_installed_names
}
}
# detects what apps are available and can be installed
# If the variants list within an app script is an empty string then
# it is considered to be too experimental to be installable
function
detect_installable_apps
{
function
detect_installable_apps
{
FILES
=
/usr/share/
${
PROJECT_NAME
}
/apps/
${
PROJECT_NAME
}
-app-
*
FILES
=
/usr/share/
${
PROJECT_NAME
}
/apps/
${
PROJECT_NAME
}
-app-
*
...
@@ -182,6 +196,7 @@ function detect_installable_apps {
...
@@ -182,6 +196,7 @@ function detect_installable_apps {
app_name
=
$(
echo
"
${
filename
}
"
|
awk
-F
'-app-'
'{print $2}'
)
app_name
=
$(
echo
"
${
filename
}
"
|
awk
-F
'-app-'
'{print $2}'
)
if
[[
$(
item_in_array
${
app_name
}
${
APPS_AVAILABLE
[@]
}
)
!=
0
]]
;
then
if
[[
$(
item_in_array
${
app_name
}
${
APPS_AVAILABLE
[@]
}
)
!=
0
]]
;
then
variants_list
=
$(
app_variants
$filename
)
variants_list
=
$(
app_variants
$filename
)
# check for empty string
if
[
${#
variants_list
}
-gt
0
]
;
then
if
[
${#
variants_list
}
-gt
0
]
;
then
APPS_AVAILABLE+
=(
"
${
app_name
}
"
)
APPS_AVAILABLE+
=(
"
${
app_name
}
"
)
APPS_CHOSEN+
=(
"0"
)
APPS_CHOSEN+
=(
"0"
)
...
@@ -236,6 +251,7 @@ function choose_apps_for_variant {
...
@@ -236,6 +251,7 @@ function choose_apps_for_variant {
get_apps_installed
get_apps_installed
}
}
# show a list of apps which have been chosen
function
list_chosen_apps
{
function
list_chosen_apps
{
app_index
=
0
app_index
=
0
for
a
in
"
${
APPS_AVAILABLE
[@]
}
"
for
a
in
"
${
APPS_AVAILABLE
[@]
}
"
...
@@ -270,12 +286,12 @@ function install_apps {
...
@@ -270,12 +286,12 @@ function install_apps {
app_index
=
0
app_index
=
0
for
a
in
"
${
APPS_AVAILABLE
[@]
}
"
for
a
in
"
${
APPS_AVAILABLE
[@]
}
"
do
do
if
[[
$
{
APPS_INSTALLED
[
$app_index
]
}
==
"0"
]]
;
then
if
[[
$
(
app_is_removed
${
a
}
)
==
"0"
]]
;
then
if
[[
${
APPS_
CHOSEN
[
$app_index
]
}
==
"
1
"
]]
;
then
if
[[
${
APPS_
INSTALLED
[
$app_index
]
}
==
"
0
"
]]
;
then
if
[
${
is_interactive
}
]
;
then
if
[
[
${
APPS_CHOSEN
[
$app_index
]
}
==
"1"
]
]
;
then
#
interactive
ly obtain settings for this app
if
[
${
is_
interactive
}
]
;
then
if
[[
$(
function_exists install_interactive_
${
a
}
)
==
"1"
]]
;
then
# interactively obtain settings for this app
if
[[
$(
app_is_removed
${
a
}
)
==
"
0
"
]]
;
then
if
[[
$(
function_exists install_interactive_
${
a
}
)
==
"
1
"
]]
;
then
install_interactive_
${
a
}
install_interactive_
${
a
}
fi
fi
fi
fi
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment