Skip to content
Snippets Groups Projects
Commit 28d5909c authored by Bob Mottram's avatar Bob Mottram
Browse files

Rename selector to addremove

parent d89ef239
No related branches found
No related tags found
No related merge requests found
......@@ -30,143 +30,153 @@
PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-selector
export TEXTDOMAIN=${PROJECT_NAME}-addremove
export TEXTDOMAINDIR="/usr/share/locale"
PROJECT_INSTALL_DIR=/usr/local/bin
if [ -f /usr/bin/${PROJECT_NAME} ]; then
PROJECT_INSTALL_DIR=/usr/bin
PROJECT_INSTALL_DIR=/usr/bin
fi
source $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-selector
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
for f in $UTILS_FILES
do
source $f
done
APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
for f in $APP_FILES
do
source $f
done
function show_apps {
applist=""
n=1
app_index=0
for a in "${APPS_AVAILABLE[@]}"
do
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
applist="$applist $n $a off"
else
applist="$applist $n $a on"
fi
n=$[n+1]
app_index=$[app_index+1]
done
choices=$(dialog --stdout --backtitle $"Freedombone" \
--title $"Installed applications" \
--checklist $'Choose:' \
80 40 20 $applist)
if [ $? -eq 0 ]; then
for choice in $choices
do
app_index = $[choice-1]
APPS_CHOSEN[$app_index]="1"
done
else
exit 0
fi
applist=""
n=1
app_index=0
for a in "${APPS_AVAILABLE[@]}"
do
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
applist="$applist $n $a off"
else
applist="$applist $n $a on"
fi
n=$[n+1]
app_index=$[app_index+1]
done
choices=$(dialog --stdout --backtitle $"Freedombone" \
--title $"Add/Remove Applications" \
--checklist $'Choose:' \
27 40 20 $applist)
if [ $? -eq 0 ]; then
for choice in $choices
do
app_index = $[choice-1]
APPS_CHOSEN[$app_index]="1"
done
else
exit 0
fi
}
function remove_apps_interactive {
# which apps need to be removed?
removals=""
app_index=0
n=0
for a in "${APPS_INSTALLED[@]}"
do
if [[ ${APPS_INSTALLED[$app_index]} == "1" ]]; then
if [[ ${APPS_CHOSEN[$app_index]} == "0" ]]; then
if [ ${n} -gt 0 ]; then
removals="$removals $APPS_AVAILABLE[$app_index]"
else
removals="$APPS_AVAILABLE[$app_index]"
fi
n=$[n+1]
fi
fi
app_index=$[app_index+1]
done
# if no apps to be removed then don't do anything
if [ ${n} -eq 0 ]; then
return
fi
# ask for confirmation
dialog --title $"Remove applications" \
--backtitle $"Freedombone" \
--defaultno \
--yesno $"\nYou have chosen to remove $n apps.\n\n $removals\n\nIf you choose 'yes' then this will remove both the applications and their data/messages. If you don't have a backup then you will not be able to recover the data for these applications.\n\nAre you sure that you wish to continue?" 15 60
sel=$?
case $sel in
1) return;;
255) return;;
esac
# remove the apps
read_configuration
remove_apps
# which apps need to be removed?
removals=""
app_index=0
n=0
for a in "${APPS_INSTALLED[@]}"
do
if [[ ${APPS_INSTALLED[$app_index]} == "1" ]]; then
if [[ ${APPS_CHOSEN[$app_index]} == "0" ]]; then
if [ ${n} -gt 0 ]; then
removals="$removals $APPS_AVAILABLE[$app_index]"
else
removals="$APPS_AVAILABLE[$app_index]"
fi
n=$[n+1]
fi
fi
app_index=$[app_index+1]
done
# if no apps to be removed then don't do anything
if [ ${n} -eq 0 ]; then
return
fi
# ask for confirmation
dialog --title $"Remove applications" \
--backtitle $"Freedombone" \
--defaultno \
--yesno $"\nYou have chosen to remove $n apps.\n\n $removals\n\nIf you choose 'yes' then this will remove both the applications and their data/messages. If you don't have a backup then you will not be able to recover the data for these applications.\n\nAre you sure that you wish to continue?" 15 60
sel=$?
case $sel in
1) return;;
255) return;;
esac
# remove the apps
read_configuration
remove_apps
}
function install_apps_interactive {
# which apps need to be installed?
installs=""
app_index=0
n=0
for a in "${APPS_INSTALLED[@]}"
do
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
if [ ${n} -gt 0 ]; then
installs="$installs $APPS_AVAILABLE[$app_index]"
else
installs="$APPS_AVAILABLE[$app_index]"
fi
n=$[n+1]
fi
fi
app_index=$[app_index+1]
done
# if no apps to be installed then don't do anything
if [ ${n} -eq 0 ]; then
return
fi
# ask for confirmation
dialog --title $"Remove applications" \
--backtitle $"Freedombone" \
--defaultno \
--yesno $"\nYou have chosen to install $n apps.\n\n $installs\n\nIf you choose 'yes' then these will now be installed.\n\nAre you sure that you wish to continue?" 15 60
sel=$?
case $sel in
1) return;;
255) return;;
esac
# install the apps
read_configuration
install_apps
# which apps need to be installed?
installs=""
app_index=0
n=0
for a in "${APPS_INSTALLED[@]}"
do
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
if [ ${n} -gt 0 ]; then
installs="$installs $APPS_AVAILABLE[$app_index]"
else
installs="$APPS_AVAILABLE[$app_index]"
fi
n=$[n+1]
fi
fi
app_index=$[app_index+1]
done
# if no apps to be installed then don't do anything
if [ ${n} -eq 0 ]; then
return
fi
# ask for confirmation
dialog --title $"Remove applications" \
--backtitle $"Freedombone" \
--defaultno \
--yesno $"\nYou have chosen to install $n apps.\n\n $installs\n\nIf you choose 'yes' then these will now be installed.\n\nAre you sure that you wish to continue?" 15 60
sel=$?
case $sel in
1) return;;
255) return;;
esac
# install the apps
read_configuration
install_apps
}
${PROJECT_NAME}-tests
if [ ! "$?" = "0" ]; then
exit 2
exit 2
fi
detect_apps
# if no applications were found
if [[ ${#APPS_AVAILABLE[@]} == 0 ]]; then
exit 1
exit 1
fi
show_apps
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment