I've tried a first time with sh like I refer to in my other post here.
I'm trying to run a bash script menu to run from terminal only.
#!/bin/bash
HEIGHT=800
WIDTH=600
CHOICE_HEIGHT=8
BACKTITLE="Installer-menu"
TITLE="Setup opions"
MENU="Choose one of the following options:"
OPTIONS=$(1 Add Mint PPA and update
2 Install Cinnamon
3 update and upgrade
4 Additional software installation
5 Upgrade Kernel
6 Resolve Ubuntu Cinnamon issues
7 Install graphic proprietary driver
x reboot )
RESULT=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
case $RESULT in
1) sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com A1715D88E1DF1F24 40976EAF437D05B5 3B4FE6ACC0B21F32 A6616109451BBBF2;
sudo sh -c 'echo "deb http://packages.linuxmint.com vanessa main upstream import backport romeo" >> /etc/apt/sources.list.d/mint.list';
sudo sh -c 'echo "deb-src http://packages.linuxmint.com vanessa main upstream import backport romeo" >> /etc/apt/sources.list.d/mint.list';
sudo apt-key export 451BBBF2 | gpg --dearmour -o /etc/apt/trusted.gpg.d/mint.gpg;
sudo apt update;;
2) sudo apt install slick-greeter muffin cinnamon;;
3) sudo apt update;
sudo apt upgrade -y;;
4) sudo sh additional-software.sh;;
5) sudo sh ubuntu-mainline-kernel.sh;;
6) sudo sh problem-solver.sh;;
7) sudo sh nvidia-installation;;
*) reboot;;
esac
and a smaller one with:
#!/bin/bash
HEIGHT=800
WIDTH=600
CHOICE_HEIGHT=8
BACKTITLE="Installer-menu"
TITLE="Package options"
MENU="Choose one of the following options:"
OPTIONS=$(1 Install package list
2 Export package list
3 update and upgrade
x reboot )
RESULT=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
case $RESULT in
1) while IFS= read -r line
do
echo "apt install -y $line"
done < installation.txt;;
2) awk -F'll ' '
/apt install/ && !/nvidia/ && !/--/ && !/-f/{ print $2 }
' /var/log/apt/history.log >installation.txt;;
3) sudo apt update && sudo apt upgrade;;
*) reboot;;
esac
$ shellcheck myscript
No issues detected!
I think I'm omitting the same thing on both. Both files are running only the last command.
Can someone enlighten me ?
I've the help of everyone I was able to run the packages (=bash script filename) menu with inside:
#!/bin/bash
width=72
height=22
menu_height=8
backtitle='Installer-menu'
title='Package options'
menu='Choose one of the following options:'
options=(1 'Install package list'
2 'Export package list'
3 'update and upgrade'
x reboot
q quit )
result=$(dialog --clear \
--backtitle "$backtitle" \
--title "$title" \
--menu "$menu" \
$height $width $menu_height \
"${options[@]}" \
2>&1 >/dev/tty)
case "$result" in
1) echo Package Install;
sh installpkgs.sh;;
2) echo Manualy installed packages exported;
sh pkgsexport.sh;;
3) echo Package upgrade;
apt update && apt upgrade -y;;
x) echo Reboot;
reboot;;
q) clear; exit ;;
esac
The two sh files contains each:
#!/bin/sh
# Export manualy installed packages
# Packages installed with apt install from terminal excl.
# Output file: installation.txt
awk -F'll ' ' /apt install/ && !/nvidia/ && !/--/ && !/-f/{ print $2 } ' /var/log/apt/history.log >installation.txt
#!/bin/sh
# Install package list
for pkg in `cat installation.txt`; do sudo apt-get install -y $pkg; done
Resulting in a working menu for all listed options:

For the installer-menu, I've tried to apply it so:
#!/bin/bash
width=72
height=22
menu_height=8
backtitle="Installer-menu"
title="Setup opions"
menu="Choose one of the following options:"
options=(1 Add Mint PPA and update
2 Install Cinnamon
3 update and upgrade
4 Additional software installation
5 Upgrade Kernel
6 Resolve Ubuntu Cinnamon issues
7 Install graphic proprietary driver
x reboot
q quit )
result=$(dialog --clear \
--backtitle "$backtitle" \
--title "$title" \
--menu "$menu" \
$height $width $menu_height \
"${options[@]}" \
2>&1 >/dev/tty)
case "$result" in
1) echo 'Mint backport repos installed';
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com A1715D88E1DF1F24 40976EAF437D05B5 3B4FE6ACC0B21F32 A6616109451BBBF2;
sh -c 'echo "deb http://packages.linuxmint.com vanessa main upstream import backport romeo" >> /etc/apt/sources.list.d/mint.list';
sh -c 'echo "deb-src http://packages.linuxmint.com vanessa main upstream import backport romeo" >> /etc/apt/sources.list.d/mint.list';
apt-key export 451BBBF2 | gpg --dearmour -o /etc/apt/trusted.gpg.d/mint.gpg;
apt update;;
2) echo 'Installation of Cinnamon';
apt install slick-greeter muffin cinnamon;;
3) echo 'Package upgrade';
apt update && apt upgrade -y;;
4) sh additional-software.sh;;
5) sh ubuntu-mainline-kernel.sh;;
6) sh problem-solver.sh;;
7) sh nvidia-installation;;
x) echo Reboot;
reboot;;
q) clear; exit ;;
esac
This is how the menu shows up:
But I forgot to enter every title between ' '

OPTIONSassignment, you appear to be confusing array construction( ... )with command substitution$( ... )RESULT=$the problem. The menu doesn't even showup. It jumps directly to the last command. Any advice is welcome. @steeldriverRESULT=$( ... )is not a problem because you are trying to substitute the output of thedialogcommand