[myHD 0.9.x] C.L.I. management

myHD is an isolated (namespace (mnt, IPC, PID)) Ubuntu environment to run Ubuntu application displayed as ASUSTOR Asportal / Xorg applications.
Post Reply
User avatar
father.mande
Posts: 1817
youtube meble na wymiar Warszawa
Joined: Sat Sep 12, 2015 2:55 am
Location: La Rochelle (France)

[myHD 0.9.x] C.L.I. management

Post by father.mande »

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
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

4.1) NEW CLI to manage Ubuntu version

Code: Select all

=====================
myHD list_ubuntu_env ... myHD list Ubuntu version used at this time
myHD switch_ubuntu_env 1804|1604 ... myHD switch to new Ubuntu version (1604 to 1804 or reverse
=====================
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
=====================
... 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)
=====================
... list_mounted_folder is used also in "status" command, just to list folder mounted (so visible) in myHD isolated environment

8.1) NEW CLI for managing

Code: Select all

=====================
myHD list_valid_folder ... list ALL valid folder able to be mounted in myHD and already selected
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
myHD list_temporary_mounted_folder ... list of temporary mounted folder
myHD mount_temporary_folder FOLDER ... mount temporary folder (/share/xxx)
myHD umount_temporary_folder FOLDER ... mount temporary folder (/share/xxx)
=====================
... part as 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 ...
... temporary mount (so not permanent after reboot) are used for network share from another system or for USB disk just plugged
... ... This is done using SSHFS from myHD to A.D.M. SO YOU MUST have ssh and sftp configured and enable in A.D.M. part
... ... ... in Ubuntu 18.04 env. sshfs is already installed in 16.04 NOT, so you must install it
... ... ... do (after an myHD apt_upgrade_package do be at last update) : myHD_root /usr/bin/apt-get -y install sshfs

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.

11) NEW CLI for managing WebUI

Code: Select all

=====================
myHD set_webui_lang LANG  ... change WebUI language to LANG (ex. en, fr, xx, etc.)
myHD display_actual_webui_lang  ... actual language in use
myHD list_available_lang_webui  ... list all language available (complete or partial en is default for missing text)
=====================
myHD add_or_update_webui_user USER PASSWORD ... add if user don't exist or update password if user exit
myHD list_webui_user ... list ALL user define in pasword protected WebUI
myHD suppress_webui_user USER ... suppress a user of the list BUT no suppress possible if only ONE user is available
=====================
Default user / password for WebUI are : myhd / asusfr1


Have fun.
Philippe.
AS6602T / AS5202T /AS5002T / AS1002T / FS6706T
Post Reply

Return to “myHD”