Front para o slackpkg em dialog

Publicado por Jefferson Rocha (última atualização em 17/02/2020)

[ Hits: 404 ]

Homepage: https://slackjeff.com.br

Download magiic




Ferramenta escrita em shell/dialog para ser um simples front para o slackpkg, voltado para os novatos. Adicione em /usr/sbin e dê permissão de execução.

  



Esconder código-fonte

#!/bin/bash
#=========================HEADER===========================================|
#
# magiic - Simple front for Slackpkg.
#
# Copyright (C) 2020 Jefferson 'Slackjeff' Rocha
# Jefferson Rocha (aka Slackjeff) [email protected]
#
# LICENSE
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
# CHANGELOG
# Please consult changelog.txt
#
#==========================================================================|

#==================== VARS
PRG='magiic'
VERSION='0.2'

#==================== FUNCTIONS
MENU() # Main menu
{
  the_menu=$(
        dialog                                 \
        --stdout                               \
        --title "Menu"                         \
        --backtitle "$PRG Version ${VERSION}." \
        --cancel-button "Exit"                 \
        --help-button                          \
        --menu  "\nWelcome to $PRG a slackpkg front...\n\nselect what you need to do in the system." \
        10 60 0                                             \
        'Mirror'  'List of Mirrors'                         \
        'Check'   'Check for system updates'                \
        'Update'  'Update the mirror'                       \
        'Clean'   'List all unofficial packages for remove' \
        'Search'  'Search for a package'                    \
        'Install' 'Install a new package'                   \
        'Remove'  'Remove a package'                        \
        'Upgrade' 'Upgrade packages'
  )
  case $? in
      1) exit 0          ;;
      2) the_menu='Help' ;;
  esac
}

MIRROR()
{
   local mirrors='/etc/slackpkg/mirrors'
    dialog                                   \
        --title "$mirrors"                   \
        --editbox "/etc/slackpkg/mirrors"    \
        0 0 2> ${mirrors}.bkp
    [[ $? -eq '0' ]] && { cp ${mirrors}.bkp ${mirrors}; rm ${mirrors}.bkp ;}
}

CHECK() #Check for system updates.
{
    dialog                                           \
        --title "Checking for a new updates"         \
        --infobox "Wait...I'll check for updates."   \
        3 50
    if slackpkg check-updates | grep -q "News on ChangeLog.txt"; then
        dialog                               \
            --title "News!"                  \
            --msgbox "News on Changelog.txt" \
            5 30
    else
        dialog                              \
            --title "No news!"              \
            --msgbox "No news is good news" \
            5 30
    fi
}

UPDATE() # Update mirror
{
    slackpkg update
}

CLEAN() # List all unofficial packages for remove.
{
    slackpkg clean-system
}

SEARCH() # Search package
{
   search=$(
      dialog                                                      \
        --stdout                                                  \
        --title "Search"                                          \
        --inputbox "What package name do you want to look for?\n" \
        0 50
   )
   [[ "$?" -eq '1' ]] && return 0
   if [[ -z "$search" ]]; then
       dialog                                                       \
           --title "Ops!"                                           \
           --msgbox "\nYou must provide a package name for search." \
           6 50
       return 1
    fi

   slackpkg search "$search"
   read -p "Press [ENTER] to continue." null

}

INSTALL() # Install package
{
   local install_pkg=$(
    dialog                                                \
        --stdout                                          \
        --title  "Install"                                \
        --inputbox "What package do you want to install?" \
        0 50
    )
    if [[ -z "$install_pkg" ]]; then
        dialog                                            \
            --title "Ops!"                                \
            --msgbox "\nYou must provide a package name." \
            6 50
        return 1
    fi

    slackpkg install "$install_pkg"
}

REMOVE() # Remove package
{
    local remove_pkg=$(
    dialog                                                \
        --stdout                                          \
        --title  "Remove"                                 \
        --inputbox "What package do you want Remove?"     \
        0 50
    )
    if [[ -z "$remove_pkg" ]]; then
        dialog                                            \
            --title "Ops!"                                \
            --msgbox "\nYou must provide a package name." \
            6 50
        return 1
    fi

    slackpkg remove "$remove_pkg"

}

UPGRADE()
{
    slackpkg upgrade-all
}

HELP() # Help Button
{
    local MSG=$(
cat <<EOF
Welcome to $PRG Help.

- WHAT IS ${PRG}?

It's a dialog front for slackpkg! Not all slackpkg options are available here.
$PRG is only meant to help with some simpler system tasks.

More detailed options available from main menu:

* Mirror
 Open a simple dialog editor for you to change the mirrors of your system. Available in /etc/slackpkg/mirrors

* Check
 Check for updates available on the system!

* Update
 Updates the mirror.

* Clean
 lists all unofficial packages that are present in the system. Ideal for cleaning up third party
 packages you don't use.

* Search
 Search for a package in the official repository.

* Install
 Install a new package.

* Remove
 Remove a package from your system.

* Upgrade
 Upgrade your system.

EOF
)

    dialog              \
        --title "Help"  \
        --msgbox "$MSG" \
        0 0
}

#=================== MAIN
while true ;do
    MENU
    case $the_menu in
        Mirror)
            MIRROR
        ;;
        Check)
            CHECK
        ;;
        Update)
            UPDATE
        ;;
        Clean)
            CLEAN
        ;;
        Search)
            SEARCH
        ;;
        Install)
            INSTALL
        ;;
        Remove)
            REMOVE
        ;;
        Upgrade)
            UPGRADE
        ;;
        Help)
           HELP
        ;;
    esac
done

Scripts recomendados

Algoritmo de Abraão - v.0.2

Cálculo de número primo

Script simples para adicionar usuarios do djbdns

Inventário de Hardware

Pinga vários IPs, tentando descobrir o hostname e MAC


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner
Linux banner
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts