It is currently Thu Nov 26, 2020 8:14 am
All times are UTC + 8 hours

[myHD 0.9.1] C.L.I. management

Who doesn't love third-party apps? Get together and talk about them here.

[myHD 0.9.1] C.L.I. management

Postby father.mande » Thu Feb 28, 2019 1:17 am

Hi,

In complement (or original) of the WebUI to manage myHD APKG ... a C.L.I. exist (and is more complete) in a terminal.
Hereafter some information on the CLI

1) YOU MUST use root (admin password) to connect you in terminal (SSH) to the NAS
... root is always present in the NAS and define as UID 0 when admin (even special) is define as UID 99
... myHD CLI REQUIRE to run as root ... so using admin can put you in problem.
... for Linux confirmed user ... it's always possible to connect you using admin user and do command using sudo (myHD command is define to run as root through sudo without password BUT only for admin user
... ... THIS IS NOT RECOMMENDED except if you know exactly what you do and why ...

2) CLI (myHD command) is auto documented (as it's possible)
... some color are used to differentiate options
myHD_CLI.png
CLI with colors
myHD_CLI.png (198.56 KiB) Viewed 1210 times


3) Basic management (as in WebUI)
Code: Select all
root@AS5002TAPHIL:/ # myHD
=====================
myHD start|stop|restart|status
=====================

... NOTHING special

4) CLI uninstall procedure
Code: Select all
===================== DANGEROUS uninstall ... it's INTERACTIVE so wait for question and read carefully output text ...
myHD uninstall_myHD ... TOTAL REMOVE myHD INCLUDING ALL associated QPKGs THEN ALL Ubuntu env. THEN myHD itself
myHD uninstall_all_myHD_APKG ... myHD remove ALL associated APKGs
myHD uninstall_Ubuntu_environment ... myHD remove ALL Ubuntu environment
=====================

... As explain it's dangerous BUT WHY I need a specific procedure
... ... myHD APKG is installed using APP. Central BUT
... ... in a second phase Ubuntu environment is installed OUT of the myHD folder 'to be saved in case of break of the APKG folder)
... ... in a third phase, one or multiple companion's APKG of myHD (using software in myHD) ... in fact launcher in Asportal can be installed
... SO uninstall APKG don't uninstall environment no more companion's APKG (unusable if myHD is removed)
... .... removing environment don't remove APKG (so a re-install will be done at next start) and don't remove companion's APKG
... ... LAST don't removing companion's APKG let unusable icons in Asportal and remove one by one can be long.
BUT this also permit to keep Ubuntu (so no reload on reinstall) to update myHD APKG without impact on installed Ubuntu software to remove launcher without removing myHD APKG

In case you uninstall myHD APKG, and want to remove companion's APKG and environment ??? shell script are provide in Environment folder ( /usr/local/.myHD )
... so you can clean your system

5) CLI to enter in isolated myHD environment
Code: Select all
=====================
myHD enter_as_root ... enter in myHD as root user
myHD enter_as_user USER_NAME ... enter in myHD as USER_NAME user (value for user_name is : astr only at this time)
=====================

... This two command are identical to
... myHD_root (enter as root) and to
... myHD_user astr (astr is for the moment the unique user USER_NAME must be astr for now up I will solve multi-users possibilities.

6) CLI for managing package in Ubuntu environment
Code: Select all
=====================
myHD apt_upgrade_package ... run apt-get update, upgrade and restart based on myHD.conf
myHD install_myHD_package TAR_FILE_NAME [PKG_NAME] ... install or update external packages (sufix .myHD MUST be PRESENT in tar file name)
=====================

... apt_upgrade_package start an apt-get update ; apt-get dist-upgrade in myHD Ubuntu to update Ubuntu and software installed (when installed using Ubuntu repository)
... install_myHD_package is to install packages inside myHD environment (integrated by any people) NEED TO BE DOCUMENTED ... sorry

7) CLI to manage INTERNAL(to Ubuntu) dropbear SSH server
Code: Select all
=====================
myHD set_sshd_port PORT .... set the port use by dropbear for next myHD dropbear server start : PORT is not verified take care
myHD restart_dropbear ... use it if you change port or keys of myHD dropbear server
myHD reset_ssh_keys ... recreate the ssh keys and install them in myHD user folder
=====================

... if for any reason (port 6222 already used) you want to change the localhost ssh server in myHD isolated environment ... here you can
... ... Dropbear local server is used to facilitate enter in myHD isolated environment (ex. use by myHD_root or myHD_user)
... restart is easy to understand
... reset_ssh_keys
... ... for having direct connection without password (ex. for some command to execute in environment) I used keys, this keys come from ssh private A.D.M. keys and are transferred to Ubuntu environment, if you want to reinstall new keys ... it's possible ... but you must understand what you do ... in normal usage IT'S NOT NECESSARY
... ... if you change A.D.M. ssh keys ... just restart myHD and new keys will be used.

8) CLI for managing visible folder by myHD (as WebUI)
Code: Select all
=====================
myHD list_mounted_folder ... list all mounted folder (so also temporary)
=====================
myHD add_include_folder [MOUNT_FOLDER_PATH_IN_myHD] ...(form : /share/xxxx ) permanent (at start) add folder to be mounted
myHD remove_include_folder FOLDER_PATH ... (like /share/xxx )
myHD list_include_folder ... list ALL folder permanently mounted in myHD
=====================

... list_mounted_folder is used also in "status" command, just to list folder mounted (so visible) in myHD isolated environment
... The three others are like in WebUI to manage the folder to add visible by myHD ... A RESTART of myHD is require to Apply new rules (add, remove)
... ... for the moment ONLY folder (shared) in /share can be used ... so entry is like /share/Media or ...

9) CLI backup (snapshot) of Ubuntu environment
Code: Select all
=====================
myHD clean_for_backup [full] ... clear man, doc and clean apt cache : full : add an autoclean (so reduce drasticaly backup size)
------------------- autoclean force to RE download packages when update / install ... so NO return to previous version NO some tools (tweek for ex.)
myHD backup_env [full] ... save snapshot of 1604 Ubuntu env. incremental or new full / home folder / scripts folder
myHD backup_home ... save ONLY the home folder (all users) to keep settings for applications ...
myHD set_backup_folder PATH_TO_FOLDER ... change the default or actual backup FOLDER (default is Errno (42): No such key!
myHD list_backup_folder ... list the actual backup_fodler
=====================

... use to get a snapshot (in fact an incremental / differential tar) of the Ubuntu (total or partial environment)
... ... for ex. just before a MAJOR update or the installation of a risky new software ...
... ... the restore is at the moment manual (due to differential snapshot possible)
... ... the backup use tar BUT with a pigz the multi-processor Gzip ... to reduce drastically the time need for a backup (pigz is also available in Entware APKG, but you can use mine in the bin folder of myHD ) .

10) CLI to manage auto-update at each myHD start
Code: Select all
=====================
myHD set_update_at_boot [on|off] ... set on or disable (off) update after start of myHD
myHD set_restart_if_update_require [on|off] ... set on or disable (off) restart after update of myHD
=====================

... restart is require in some case (update of Ubuntu core libraries) ... you can do it yourself or manage to do it automatically ONLY if require by Ubuntu after dist-upgrade
... ... absolutely not mandatory ... just a choice.

Have fun.
Philippe.
AS5202T /AS5002T / AS202TE / AS1002T
My Blog specific to my APKG : https://blog.father-mande.ovh/
User avatar
father.mande
 
Posts: 1047
Joined: Sat Sep 12, 2015 2:55 am

Return to Developer's Corner

  • You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot post attachments in this forum
  • Who is online

    Users browsing this forum: No registered users and 1 guest