Quick start for Mac OS

You can deploy small-shell to Mac OS as well. We are thinking that Mac mini could be a mini server for working with small team.

Setup Env on Mac terminal

# addd user
sudo dscl . -create /Users/small-shell
sudo dscl . -create /Users/small-shell UserShell /usr/bin/false
sudo dscl . -create /Users/small-shell UniqueID 1001 
sudo dscl . -create /Users/small-shell PrimaryGroupID 1001
sudo dscl . -create /Users/small-shell NFSHomeDirectory /Users/small-shell

# addd group
sudo dscl . -create /Groups/small-shell PrimaryGroupID 1001

# create directory
sudo mkdir /Users/small-shell
sudo chown small-shell:small-shell /Users/small-shell

# install brew if it's not installed yet
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# insetall basic command
brew install jq
brew install php
brew install gnu-sed
brew install gnu-awk
#brew install sha3sum
brew install flock
brew install node

Change sleep setting

Also you need to change sleep setting on GUI to avoid service down when display is off. setting should be done from System preference > Security & Privacy > Power Adaptor

Note

Please check "Prevent your Mac from automatically sleeping when the display is off"

Installation

# install
cd /usr/local
sudo git clone https://github.com/small-shell/small-shell.git
sudo chown -R small-shell:small-shell /usr/local/small-shell
sudo chmod 755 /usr/local/small-shell/adm/gen

Generate Databox

Then Let's generate databox as the data store of WEB APP. DATA shell details are in DATA shell tour

sudo /usr/local/small-shell/adm/gen -databox
#-> dialog will be started

Note

You can exit dialog anytime with ctrl + C

Dialog

In this expamle, "item_name" is set as priary key.

Databox Name: item.db
primary_key(col1): item_name
primary_key label: Item Name
Do you want to add column to dataset? (yes | no): yes
key(col2) name: description
key(col2) label: Description
Data Type (text | select | radio | checkbox | email | num | tel | date | date-time | url | textarea | file | pdls | mls): text
Require to input each time? (yes | no): yes
Do you want to add more column to dataset? (yes | no) : no


Data box will be generated by following order, please check it
-----------------------------------------------------------------
databox_name:item.db
#primary_key
name="item_name"
label="Item Name"
type="text"
option="required"

#column2
name="description"
label="Description"
type="text"
option="required"
-----------------------------------------------------------------

Is it OK? (yes | no): yes

Generare Base APP

Once at least 1 databox is ready, please generate APP shell
APP shell details are in APP shell tour

sudo /usr/local/small-shell/adm/gen -app
Type of APP (1.BASE | 2.FORM | 3.SCRATCH): 1
Type of server (1.small-shell WEB srv | 2.other WEB srv): 1
protocol (http | https): https
WEB Server FQDN or IP addr (e.g. 192.168.10.1): ec2-XX-XX-XX-XX.us-west-2.compute.XXXX.com
ssl cert path : /root/cert.pem
ssl privare key path : /root/private.pem
Do you need to use chain certificate ? (yes | no): no

Add user

Following example is adding user name "test", "test" can initialize and get base64 key by accessing the URL that is generated by ops command

sudo /usr/local/small-shell/adm/ops add.usr:test

By the way, this URL can be accessed only 1 time. please inform to the user.

-----------------------------------------------------------------
Key initializing & generating URL for test on Base APP is here
-----------------------------------------------------------------
https://$server/cgi-bin/auth.base?initialize=*****109a7126be47d5049cd7d5c440,6bc0917d9510ae794ab5cb5d1e65834c09ad11fbd3d78db881a656c591d1604a

End user can access to the Base APP by click the button and key will be stored to local storage of browser.

Screenshot

Connect to the Base APP

Image of authentication page of Base APP is as following. the access URL will be shown in the end of the gen dialog but basically it will be "https://$FQDN/base". key will be inserted automatically if it's stored in local storage. Screenshot

Then end user can use following APP features as default. ofcourse you can make your own APP, please see detail on Create Scratch APP

Base APP FEATURES

  • Push or Get datas thorough simplest UI
  • Can use "And" search using space [e.g. word1 word2]
  • Multi type of sort using sort command
  • Serch using specific key of column, [e.g key{wordA}]
  • Download search result by CSV format
  • Import Data with CSV format
  • Define number of line per page [e.g #line:20] [e.g word #line:20]

Screenshot

+ Command Console

  • Analyze data using linux commands [grep, wc, awk, uniq, sed, tail, head, nl, sort, cut ..]
  • Search log with freewords by adding tag [e.g. word1 word2 #log]
  • Show statistics #stats, you need to define statistics job. Please see the pyshell for further details.

Screenshot

Re-generate initialize URL

If end user lost their key, you can re-generate initialize URL by following command. In this example, admin will re-generate initialize URL for user name "test"

 sudo /usr/local/small-shell/adm/ops initialize.usr:test

Re-start web server

You can restart web server by launchctl command

# restart
sudo launchctl stop org.small-shell.node
sudo launchctl start org.small-shell.node

# check process
ps -ef | grep app.sh
# check log
ls /var/www/log

Enable cron access

If you want to use e-cron, you need to allow cron to access data by changing privacy setting. setting should be done on GUI from System preference > Security & Privacy > FUll Disk Access.

Note

Please add /usr/sbin/cron by using command+shift+G shortcut on FUll disk Access setting.

Update to latest version

You can updsate small-shell very easily. this is exmaples of update procedure.
Once you clone the latest code, it's recommended to re-generate Base APP.
Even if Base APP has been upgraded, you can keep to use user key, ssl cert & key, API key.

cd /var/tmp
sudo git clone https://github.com/small-shell/small-shell.git
sudo \cp -Rf small-shell/* /usr/local/small-shell/
sudo rm -rf small-shell

# re-generate Base APP
sudo /usr/local/small-shell/adm/gen -app
-----------------------------------------------
Type of APP (1.BASE | 2.FORM | 3.SCRATCH): 1
------------------------------------------------
-> dialog will be started