PINE64
Bash script for common errors - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PinePhone (https://forum.pine64.org/forumdisplay.php?fid=120)
+--- Forum: PinePhone Software (https://forum.pine64.org/forumdisplay.php?fid=121)
+---- Forum: UBPorts on PinePhone (https://forum.pine64.org/forumdisplay.php?fid=125)
+---- Thread: Bash script for common errors (/showthread.php?tid=9098)



Bash script for common errors - aleadom - 02-09-2020

Hello, I´ve done a little script for common errors on UBports, specially useful for me on sound and modem. I hope you find it useful and improve it, I don´t know how to set the variable ip to the command ssh. I hope they solve soon this errors soon but in the meantime...


It´s on Spanish but:

1) WIFI RESET                          ...
2) ACTIVAR SIM                        Sim

3) ACTIVAR SONIDO                  Sound

4) ACTUALIZAR SISTEMA           System update





Code:
 #! / bin / sh

show_menus() {
   

    echo -e "********************************************** "

    echo -e "** $  1) WIFI RESET                         ** "

    echo -e "** $  2) ACTIVAR SIM                        ** "

    echo -e "** $  3) ACTIVAR SONIDO                     ** "

    echo -e "** $  4) ACTUALIZAR SISTEMA                 ** "

    echo -e "** $  5) SSH                                ** "

    echo -e "**********************************************  "

    echo -e "Ingrese una opción de menú y ingrese o ingrese para salir. "

    read opt


}

function option_picked () {


    echo -e

}


clear

show_menus

while : ;

    do

more

        case $opt in

        1) clear;

        option_picked "Opción 1 escogida";

sudo nmcli radio wifi off

sudo nmcli radio wifi on
     
sudo poweroff


show_menus;

        ;;


        2) clear;

            option_picked "Opción 2 escogida";

sudo /usr/share/ofono/scripts/enable-modem

sudo /usr/share/ofono/scripts/online-modem

        show_menus;

            ;;


        3) clear;

            option_picked "Opción 3 escogida";

modprobe snd_soc_simple_amplifier

modprobe snd_soc_simple_card_utils

amixer -c 0 set 'AIF1 Slot 0 Digital DAC' unmute

amixer sset 'Line Out' 100%;

            show_menus;

            ;;


        4) clear;

            option_picked "Opción 4 escogida";

sudo apt update && sudo apt upgrade;

           show_menus;

            ;;



        x) exit;

        ;;



        \ n) exit;

        ;;



        *)clear;

        Opción_pulsada "Elija una opción del menú";

        show_menus;

        ;;

    esac



done



RE: Bash script for common errors - PinePhoneCoder - 02-10-2020

Nice! You made a nice menu I see. I did sort of the same thing: Bash scripts for the basic functions of the PinePhone on GitHub: https://github.com/dirkjanbuter/pinephone-commands (I try to keep it up to date).


RE: Bash script for common errors - tcode - 02-12-2020

(02-10-2020, 08:54 AM)PinePhoneCoder Wrote: Nice! You made a nice menu I see. I did sort of the same thing: Bash scripts for the basic functions of the PinePhone on GitHub: https://github.com/dirkjanbuter/pinephone-commands (I try to keep it up to date).

Have successfully tested several your scripts. Thank you.
However, after a recent update when I turn on the modem with the script, drop the wifi connection. When restore the wifi connection, drop the modem.


RE: Bash script for common errors - undo - 02-13-2020

(02-10-2020, 08:54 AM)PinePhoneCoder Wrote: Nice! You made a nice menu I see. I did sort of the same thing: Bash scripts for the basic functions of the PinePhone on GitHub: https://github.com/dirkjanbuter/pinephone-commands (I try to keep it up to date).

Hey, thanks for the script collection. Here's a little suggestion: I made a hidden script in the folder like this:




Code:
#!/bin/bash
scriptdir=$HOME/cmd/

cd $scriptdir
ls -1 | nl
echo "Make your choice"
read choice
choicetorun=$(ls -1 | nl -s \: | sed -e 's/^[ \t]*//' | grep ^"$choice"\: | sed -e 's/[0-9]\://' | sed -e 's/^[0-9]//')
./$choicetorun


It makes a list of the folder, like so:


Code:
pine:~/pinephone-commands/.la.sh
     1    change-password.sh
     2    ear-on.sh
     3    image-to-internal-storage.sh
     4    install-ffmpeg.sh
     5    install-samba.sh
     6    install-tor-site.sh
     7    killer.sh
     8    mixer.sh
     9    radio-nl-bnr.sh
    10    radio-nl-qmusic.sh
    11    speaker-half.sh
    12    speaker-max.sh
    13    speaker-mute.sh
    14    speaker-on.sh
    15    tor-my-domain.sh
    16    wifi-reset.sh
Make your choice


And you can choose the script you want by number. And if you add a script in the folder, you won't have to modify a file for to have a menu selection.


RE: Bash script for common errors - Goddard - 02-13-2020

Nice work. I will test these out.

Just to add to the collection.

I made an install script for UBPorts. Hopefully expand more later.
https://github.com/goddard/pinephone

Anyone played with installing over USB?


RE: Bash script for common errors - PinePhoneCoder - 02-14-2020

(02-13-2020, 08:11 AM)undo Wrote:
(02-10-2020, 08:54 AM)PinePhoneCoder Wrote: Nice! You made a nice menu I see. I did sort of the same thing: Bash scripts for the basic functions of the PinePhone on GitHub: https://github.com/dirkjanbuter/pinephone-commands (I try to keep it up to date).

Hey, thanks for the script collection. Here's a little suggestion: I made a hidden script in the folder like this:




Code:
#!/bin/bash
scriptdir=$HOME/cmd/

cd $scriptdir
ls -1 | nl
echo "Make your choice"
read choice
choicetorun=$(ls -1 | nl -s \: | sed -e 's/^[ \t]*//' | grep ^"$choice"\: | sed -e 's/[0-9]\://' | sed -e 's/^[0-9]//')
./$choicetorun


It makes a list of the folder, like so:


Code:
pine:~/pinephone-commands/.la.sh
     1    change-password.sh
     2    ear-on.sh
     3    image-to-internal-storage.sh
     4    install-ffmpeg.sh
     5    install-samba.sh
     6    install-tor-site.sh
     7    killer.sh
     8    mixer.sh
     9    radio-nl-bnr.sh
    10    radio-nl-qmusic.sh
    11    speaker-half.sh
    12    speaker-max.sh
    13    speaker-mute.sh
    14    speaker-on.sh
    15    tor-my-domain.sh
    16    wifi-reset.sh
Make your choice


And you can choose the script you want by number. And if you add a script in the folder, you won't have to modify a file for to have a menu selection.

Nice "undo", will try that later.

(02-13-2020, 02:25 PM)Goddard Wrote: Nice work.  I will test these out.

Just to add to the collection.  

I made an install script for UBPorts.  Hopefully expand more later.
https://github.com/goddard/pinephone

Great!

(02-13-2020, 02:25 PM)Goddard Wrote: Anyone played with installing over USB?

No, but do you have an idea where to start?


RE: Bash script for common errors - dukla2000 - 02-14-2020

(02-14-2020, 04:43 AM)PinePhoneCoder Wrote:
(02-13-2020, 02:25 PM)Goddard Wrote: Anyone played with installing over USB?

No, but do you have an idea where to start?

Unless I am very much mistaken you have to use FEL mode. And, again unless I am mistaken, the PinePhone has no magic button key sequences to boot into FEL mode (although I am curious about the reset button ...) so you either have to use the special SDcard image or ensure there is no bootable image on both the SDcard and the eMMC.

ps - getting off topic, may warrant a new thread


RE: Bash script for common errors - PinePhoneCoder - 02-14-2020

(02-14-2020, 04:58 AM)dukla2000 Wrote: ps - getting off topic, may warrant a new thread
See https://forum.pine64.org/showthread.php?tid=9161 for the new thread.