nanopi-neo--System Configuration Tool Npi-config

Source: Internet
Author: User
Tags ftp commands ftp connection time zones ssh git clone


Npi-config is a command line system Configuration Tool under our Nanopi-neo system that allows you to perform some initialization configuration of the system, including user passwords, system languages, time zones, Hostname, SSH switches, automatic login options, and more. You can enter at the command line by executing the following command:



sudo npi-config


The npi-config display interface looks like this:




Figure 1.17 The display interface of the System Configuration Tool Npi-config






The current version of the Npi-config tool has a total of 8 menus: change user Password: Modify the Default user's login password Hostname: set hostname, default to Nanopi-neo boot options: Configure some startup option, For example, the default User localisation option: Configure some local options, such as language, time zone, keyboard layout, Wi-Fi band, etc. interfacing options: interface option configuration, for example, turn on or off SSH service Advanced Options: Advanced configuration, including Audio, welcome information update: Upgrade Npi-config to latest version about Npi-config: About Npi-config



The use of Npi-config is very simple, according to the prompts to operate it, generally will not have too much problem, here is not explained in detail, we have to explore several times on it.



When I select "Update" I see the following tips:



Cloning into ' npi-config '
... Remote:counting objects:5, done.
Remote:total 5 (Delta 0), reused 0 (Delta 0), pack-reused 5
unpacking objects:100% (5/5), done.
Checking connectivity ... done.
Sleeping 5 seconds before reloading Npi-config


Thus, guessing the update operation of the Npi-config tool is to pull up the latest code for the Git repository, find the relevant warehouse on GitHub, and then try to clone the Npi-config source code with the following command:



git clone https://github.com/friendlyarm/npi-config.git


The clone was successful and you can see that there are three files in the Npi-config directory:



Npi-config   readme.md  sample_profile_d.sh


Where Npi-config is the System Configuration tool we run above, in fact, it is a Shell script file. Here's a partial code:


#!/bin/sh
# Part of npi-config http://github.com/friendlyarm/npi-config
#
# See LICENSE file for copyright and license details

INTERACTIVE=True
ASK_TO_REBOOT=0

if [ -f /etc/friendlyelec-release ]; then
  # get friendlyelec's boardt model
  # example: 
  # BOARD="NanoPC-T2"
  # LINUXFAMILY=nanopi2
  . /etc/friendlyelec-release                       
fi

......

do_update() {
  cd /tmp/
  rm -rf npi-config
  git clone https://github.com/friendlyarm/npi-config
  if [ $? -eq 0 ]; then
    SELFPATH=`which npi-config`
    cp -f npi-config/npi-config $SELFPATH
    chmod 755 $SELFPATH
    rm -fr npi-config
    printf "Sleeping 5 seconds before reloading npi-config\n" &&
    sleep 5 &&
    exec $SELFPATH
  else
    whiptail --msgbox "There was an error checking new version." 20 60 1
  fi
}

#
# Interactive use loop
#
calc_wt_size
while true; do
  FUN=$(whiptail --title "NanoPi Software Configuration Tool (npi-config)" --menu "Setup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Finish --ok-button Select \
    "1 Change User Password" "Change password for the default user (pi)" \
    "2 Hostname" "Set the visible name for this Pi on a network" \
    "3 Boot Options" "Configure options for start-up" \
    "4 Localisation Options" "Set up language and regional settings to match your location" \
    "5 Interfacing Options" "Configure connections to peripherals" \
    "6 Advanced Options" "Configure advanced settings" \
    "7 Update" "Update this tool to the latest version" \
    "8 About npi-config" "Information about this configuration tool" \
    3>&1 1>&2 2>&3)
  RET=$?
  if [ $RET -eq 1 ]; then
    do_finish
  elif [ $RET -eq 0 ]; then
    case "$FUN" in
      1\ *) do_change_pass ;;
      2\ *) do_change_hostname ;;
      3\ *) do_boot_behaviour ;;
      4\ *) do_internationalisation_menu ;;
      5\ *) do_interface_menu ;;
      6\ *) do_advanced_menu ;;
      7\ *) do_update ;;
      8\ *) do_about ;;
      *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
    esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
  else
    exit 1
  fi
done


Did you see do_update? Obviously just the conjecture was right. Well, a friend interested in Npi-config's implementation can then parse the script. On the terminal is too inconvenient to see, I decided to take it out with notepad++ to see, that how to take it.
Open SecureCRT and login with SSH Nanopi-neo (see section if you don't understand). When the login is successful, press Alt+p to open a new session for FTP operation. It is estimated that the FTP server is logged in using local user mode, and I am logged in with root, so the current directory is the home directory of root. OK, log in to FTP, you can use get to download the file, the operation is as follows:



sftp> ls
mjpg-streamer     Music     npi-config    test.pcm
sftp>
pwd/root sftp> get Npi-config/npi-config
downloading npi-config from/root/npi-config/npi-config
  100% 19KB     19KB/s 00:00:00     
/root/npi-config/npi-config:20247 bytes transferred in 0 seconds (kb/s)


If the download is successful, do not know where the file is stored, you can choose "Options" –> "Session Options" –> "SFTP Sessions" in SecureCRT, view "local directory" Just know where the downloaded file is stored. Then you can use notepad++ to analyze npi-config well.



About FTP commands, you can enter Help to view the FTP provides all the commands, here are some commonly used commands: PWD: Query Linux host directory (that is, remote host directory) lpwd: query local directory (generally refers to the directory of Windows uploaded files) ls: check Inquire what files are connected to the current Linux host directory lls: Query current local upload directory what files LCD: Change the path of the local upload directory CD: Change the remote upload directory get: Download the files in the remote directory to the local directory put: Upload the files in the local directory to the remote host ( Linux) Quit: Disconnect FTP connection


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.