This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
hugeblank's profile picture

HUG. The Advanced Extended Shell | Bag Included!

Started by hugeblank, 17 September 2017 - 07:30 AM
hugeblank #1
Posted 17 September 2017 - 09:30 AM
HUG.

Hug is an Advanced Extended Shell that works *with* you! Hug contains various features that developers can take advantage of, and users can enjoy. Let's take a look at them!

Bag(el):

Bag is a package manager that takes raw file links from databases on pastebin, and puts them into a file form that can be updated by the user with a single command.

Spoiler

Usage:

This is the general information about Bag. If you are a general user, you may want to take a look at some of these commands.

Spoiler

bag addbase <raw file link> --Adds a bag database to the list of databases, and makes all packages on that database available.
bag grab <package name> --downloads a program from a bag database, and adds it to your "bag"; a list of packages that have been downloaded.
bag update --updates all packages in your bag to the latest version.
bag remove <package name> --removes an installed package, and takes it out of your bag.

bag list –lists all packages contained within the databases added

bag info <package name> –gives info about the package, if any is provided.



Databases:

Databases allow for developers to provide a centralized place for users to download their applications and scripts from. If you are a developer, or want to make a database, take a look in here.

SpoilerHere's an example of a small database containing some junk code:

button_API https://pastebin.com/raw/m9bW67Fi /lib/API/button "1.0" A small button API for scripts that desire more interaction
smartRead_testing https://pastebin.com/raw/HGk9JfNg ~/smartRead.lua "1.0"
As you can see, the format is: package name, raw file link, install location, version, information.There also are some notable things about the way the databases are formed, and more importantly rules that really need to be followed.
[indent=1]1. "~" can be used in replacement of "/home/<user>" in the install location. This is very nifty when you want a file in the home directory of the logged in user.[/indent]
[indent=1]2. The install location must have the file name built in. For example, ~/smartRead.lua. Bag sees this, and will put the file in "/home/<user>/smartRead.lua"[/indent]
[indent=1]3. The version number must be in quotes. If it isn't, things like 1.0 will turn into 1, and 1.0.1 will cause crashes. If you like people, use quotes.[/indent]
[indent=1]4. Bag doesn't look past comments ("–like this one") quite yet. This is a feature I would like to implement, but haven't gotten to quite yet. :P/>[/indent]
I would really like to see the creation of other databases, and so to promote that, I will be featuring any databases that come my way (through any means be it discord, or through the forums) providing a detailed description of the contents, and the Database Link. I look forward to seeing them! :D/>

Settings:

HUG comes with some settings that allow manipulation of how it boots up, and what it boots to.

Spoiler


boolean hug.use_bootLoader --Enable or disable the bootloader. Default: false
boolean hug.use_greeter --Enable or disable the greeter. Default: true
string hug.greeterLocation --The location of the greeter. Default: "/lib/greeter.lua"
boolean hug.use_init --Enable or disable "/boot/init.lua". Default: true
string hug.defaultEditor --The file location of the editor to use by default. Default: "/rom/programs/edit"
string hug.boot --Set the path to boot up from (Used primarily from the boot loader). Default: "/lib/hug.lua"
All of these settings can be easily tweaked to allow for a more personalized hug shell.

Boot Loader:

The boot loader is a simple way to swap between using Hug, CraftOS, any other operating system, shell, or program, you name it.

SpoilerIt is a lua script that is run before the greeter and shell. By default it is disabled, but can be enabled by setting "hug.use_bootLoader" to true. The boot loader is stored in /boot/loader.lua. By default there is a basic bootloader built in that allows the user to switch between CraftOS and HUG. Please feel free to create your own boot loader, and share it with me! I will be featuring any I get (much like bag databases :P/>). To remove the current bootloader, which you may want to do if you are creating your own, run "bag remove loader.lua"
Greeter:

The greeter is a script that runs after the boot loader (if it's enabled), allows for users to log in near securely.

SpoilerThe greeter should provide a way to swap between existing users (via "/var/.userlist"), and once a user is selected, prompt them for a password if there is any. To disable this feature, change the setting "hug.use_greeter" to false. If you want to change what the greeter executes, you can use the setting "hug.greeterLocation", and by default it is set to "/lib/greeter.lua".

NOTE: At this point in time, this feature is very limited in what it prevents, considering that CraftOS is right around the corner, and I haven't yet implemented the permission system (Yes, it's coming, and no, not very quickly…). Without the permission system, any user can access any file, and if they don't have a password set… then things can go wrong very quickly. Please feel free to disable this using the method described above, or use only a single user. A single user with a password, as set by the program "passwd", is perfectly secure, so long as the boot loader is disabled.
init.lua:

init.lua is the replacement for "startup.lua". As you may have noticed, hug is a big startup hog.

SpoilerSimply put, init.lua = startup.lua. if you want to execute something on initialization, it is put into /boot/init.lua, and on startup, after the greeter finishes executing, init.lua is run. If you don't want init.lua executed, simply disable "hug.use_init" in the settings.

NOTE: I plan on changing this feature so that init.lua's are user specific, in the user's home directory ("/home/<user>"). Expect this change very soon.
Other Information:

A little list of other features that are convenient, and probably good to know

Spoiler
  • files in /etc and /lib are added to autocompletion (with ".lua" stripped)
  • adduser adds a user to user list, and makes a home directory for them.
  • passwd sets or changes the logged in users password.
  • deluser deletes a user, removes their home directory, and any password or salt files they may have had
  • ~ is a thing. Rejoice!
  • Autocompletion ("/lib/extend.lua") is a default feature, it wouldn't really be "Advanced" without it… (indirectly sponsored by Wojbie. Give him an upvote.)
  • hug settings. Tweak all the little bits and bobs on bootup. (Also indirectly sponsored by Wojbie)
  • Computer names, set from the "/var/.domain" file. (Replacing with os.getComputerLabel() Soon)
  • "ls" is both pretty and functional! Hide specific files using "/var/blacklist.txt". Putting -h as the first command will show all hidden files.
Soon™:

A not so little list of all the plans I have made for Hug.

Spoiler
  • /var/.domain is unnecessary, replace it with os.getComputerLabel(). Done!
  • Re-implement shell.openTab(). Dunno how, but I'll work it back in one way or another.
  • Permission System… this one is going to be a doozie.
  • Allow comments in Bag databases.
  • Seperate file location, and file name, so that the package name doesn't have to be the same thing as the file name in Bag database. Done!
  • "bag info <package name>": Provides information about the package. Done!
  • grep (glpp [Globally search a Lua Pattern and Print])
Install:

All the information you're going to need to install Hug (not much)

SpoilerInstaller:

pastebin run ccS5acce
The default username is "root", and it has no password, but it is highly recommended that you set one.
The installer installs Bag, adds the Hug Mainline Database, downloads all packages off of it, asks you to set the computer label, and reboots.

If you have any issues with Hug, be it functionality or some other reason, please drop a ticket in the issue tracker. I'll try to be as active as I can to get fixes as quickly dealt with as possible.

Please feel free to manipulate Hug in any way you want, as a matter of fact, I encourage it. Hug is meant to work with you, and if that means tweaking of any of the code I wrote, then by all means do it. All of my scripts for Hug are on github, for you to have a look at. (optionally you can just look at it through a computer…)

Feel free to show me your customization, I really like seeing how others use my applications and scripts! :D/>
Remember, I also want to feature other users bag databases, boot loaders, and greeters! If you create any of these, I really want you to get in touch with me! :P/>

Oh, and don't forget to upvote! ;)/>
hugeblank #2
Posted 17 September 2017 - 07:16 PM
Some minor tweaks went live just now:
  • tweaked the bag database format, as described in Soon.
  • /lib/API/sha now has salting implemented like it's supposed to… my mistake for redirecting to the original
  • /lib/extend.lua broke in version 1.80 and onwards. Wojbie fixed this issue, and released a new version. I implemented a version check so that the proper version of extend gets added.
  • Moved most everything Hug related over to a git repo.
  • Bag got a tweak to allow databases other than raw pastebin links.
  • The main database is also getting moved over to github. It is highly recommended that if you installed Hug before this change that you update using "bag update", run the command "bag transform", and run "bag update" again. Just like that you'll be right back on the mainline.
  • Hug shell now uses the computer label in replacement of "domain", as mentioned in Soon. If no label is set, it falls back to the computers ID.
  • Added "bag info <bag-package>" and "bag list".
Edited on 17 September 2017 - 11:14 PM
Dave-ee Jones #3
Posted 18 September 2017 - 01:04 AM
Look, it's Linux! :P/>

From what I've read it sounds good! I'll try it out..
hugeblank #4
Posted 20 September 2017 - 03:29 PM
Look, it's Linux! :P/>

From what I've read it sounds good! I'll try it out..

That's kind of the end goal of this project, I have a few things on the way that more closely resemble a linux command line. (grep :P/>)

Thank you, Please do!
hugeblank #5
Posted 20 September 2017 - 03:56 PM
Minor bugfix update:
  • bag disliked when the file link did not actually lead to a file, a conditional has now been added to change that.
  • blacklist.txt has been removed so that when you make your own it doesn't get overwritten. As a matter of fact it's advised that you remove it, as having it stick around in your bag is not optimal. (but you can keep it if you want…)
  • Installer updated to pull the latest version of bag, rather than the one from pastebin.
I have some pretty bomb features on their way, the one I'm focused on currently is a lua form of grep. I've made a lot of progress, and I have a lot more progress to make, but it IS coming!