Globally install with npm
:
$ npm i -g gagu
You may need command sudo
in macOS:
$ sudo npm i -g gagu
Show help info:
$ gagu -h
$ gagu --help
Start service:
$ gagu
Start and open in browser:
$ gagu -o
$ gagu --open
Start with HTTPS:
$ gagu -s
$ gagu --security
Start with a specified Host:
$ gagu -H 0.0.0.0
$ gagu --Host 0.0.0.0
Start with a specified port:
$ gagu -p 80
$ gagu --port 80
Show version:
$ gagu -v
$ gagu --version
Remove GAGU data directory WORKSPACE/.io.gagu/data
:
$ gagu --reset
Remove GAGU root directory WORKSPACE/.io.gagu
:
$ gagu --reset-all
Stop service:
# `Ctrl + C` or close terminal
The running of GAGU needs to provide a local root directory of its own GAGU_PATH.ROOT
to store some data.
Every time the service is started, GAGU will detect whether the root directory exists, and if it does not exist, it will automatically create a root directory named .io.gagu
in the workspace.
Different platforms will choose different workspaces to create. Here, it is assumed that the user name of the login device is jay
:
C:/Users/jay/.io.gagu
/Users/jay/.io.gagu
/home/jay/.io.gagu
/data/data/com.termux/files/home/.io.gagu
/data/data/com.termux/files/home/storage/shared
points to the internal storage mounted by the Android system, which needs to be obtained through termux-setup-storage
in Termux.
For the use of Termux, please refer to Termux Wiki or Termux Advanced Terminal Installation and Configuration Tutorial.
GAGU’s root directory .io.gagu
is a hidden folder named at the beginning of .
, which can be displayed on the device through specific settings, but will be forcibly filtered in GAGU’s API, even if it has Users with administrator rights cannot access it in GAGU’s Web page.
After the root directory is successfully created, the following subdirectories will continue to be created:
.io.gagu
|- data
|- log
|- public
| |- avatar
| |- image
| |- lib
|- secrets
|- thumbnail
|- users
data
is used to persistently store some data files in JSON format such as users, logins, download tunnels, settings, etclog
is used to store API logpublic/avatar
is used to store the user’s avatar, and the file name is the usernamepublic/image
is used to store some config imagespublic/lib
is used to store third-party js libraries that may be used in the futuresecrets
is used to store HTTPS PEM filesthumbnail
is used to store thumbnails generated in useusers
is used to store user’s personal filesWhen accessing a file that can display thumbnails in GAGU’s File Explorer, GAGU will use the “full path” of the file plus “modification time” to perform md5
operations to obtain a 32-bit string, and then request the thumbnail file with the same name as the string under .io.gagu/thumbnail
, if it does not exist, call the thumbnail interface to generate and return.
const { mtimeMs } = statSync(path)
const thumbnailId = md5(`${path}-${mtimeMs}`)
Therefore, when the file does not change (move location or modify), it will take a certain amount of time to obtain the thumbnail for the first time. You can use the “Thumbnail Actively Generating” feature in the “Settings” for the directory containing the thumbnail files that need to be displayed. features to enhance the browsing experience.
GAGU will use ffmpeg and GraphicsMagick interfaces when generating thumbnails, you can decide whether you need to install them, if not, it will not affect the use of GAGU’s main functions, and all files will be displayed with default type icons.
The default port number of the GAGU service is 9293
. After the service is started, it can be accessed locally through http://127.0.0.1:9293
. When accessing other devices in the LAN, replace the IP in it with the intranet IP of the server device.
I assigned a fixed IP
192.168.31.13
to the 13-inch Mac in my home router, and pointed the domainmac.io
in the hosts of the router to192.168.31.13
, and started the GAGU service on the Mac with port80
, now, every device in the LAN can accesshttp://mac.io
through a browser to use the GAGU service on the Mac. I also specified the shorter domaini.io
for my mobile phone.
There are two ways to modify the port number:
gagu -p 80
(binary version does not support)The modification of command parameters has the highest priority, followed by the modification in the settings, and the last is the default port number.
When starting the service for the first time, GAGU will automatically generate a default account with full permissions.
Username: gagu
Password: 9293
When you log in for the first time, you can only log in with the default account.