Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "libwired"]
path = libwired
url = https://github.com/nark/libwired
url = https://github.com/profdrluigi/libwired
branch = master
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WD_MAINTAINER = 0
WD_USER = nark
WD_GROUP = daemon

DISTFILES = INSTALL LICENSE NEWS README Makefile Makefile.in \
DISTFILES = INSTALL LICENSE NEWS README.md Makefile Makefile.in \
config.guess config.status config.h.in config.sub configure \
configure.in install-sh libwired man run thirdparty wired
SUBDIRS = libwired
Expand Down Expand Up @@ -149,6 +149,19 @@ install-wired:
$(INSTALL) -m 644 -o $(WD_USER) -g $(WD_GROUP) $(rundir)/banner.png $(installdir)/; \
fi

if [ ! -f $(installdir)/robo.png ]; then \
$(INSTALL) -m 644 -o $(WD_USER) -g $(WD_GROUP) $(rundir)/robo.png $(installdir)/; \
fi

@if [ ! -p $(installdir)/WiredBot ]; then \
if [ -e $(installdir)/WiredBot ]; then \
echo "Error: $(installdir)/WiredBot exists and is not a named pipe"; \
exit 1; \
fi; \
mkfifo -m 660 $(installdir)/WiredBot; \
chown $(WD_USER):$(WD_GROUP) $(installdir)/WiredBot; \
fi

$(INSTALL) -m 644 -o $(WD_USER) -g $(WD_GROUP) $(rundir)/wired.xml $(installdir)/
$(INSTALL) -m 755 -o $(WD_USER) -g $(WD_GROUP) $(rundir)/wired $(installdir)/
$(INSTALL) -m 755 -o $(WD_USER) -g $(WD_GROUP) $(rundir)/wiredctl $(installdir)/
Expand Down
15 changes: 14 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WD_MAINTAINER = @WD_MAINTAINER@
WD_USER = @WD_USER@
WD_GROUP = @WD_GROUP@

DISTFILES = INSTALL LICENSE NEWS README Makefile Makefile.in \
DISTFILES = INSTALL LICENSE NEWS README.md Makefile Makefile.in \
config.guess config.status config.h.in config.sub configure \
configure.in install-sh libwired man run thirdparty wired
SUBDIRS = libwired
Expand Down Expand Up @@ -149,6 +149,19 @@ install-wired:
$(INSTALL) -m 644 -o $(WD_USER) -g $(WD_GROUP) $(rundir)/banner.png $(installdir)/; \
fi

if [ ! -f $(installdir)/robo.png ]; then \
$(INSTALL) -m 644 -o $(WD_USER) -g $(WD_GROUP) $(rundir)/robo.png $(installdir)/; \
fi

@if [ ! -p $(installdir)/WiredBot ]; then \
if [ -e $(installdir)/WiredBot ]; then \
echo "Error: $(installdir)/WiredBot exists and is not a named pipe"; \
exit 1; \
fi; \
mkfifo -m 660 $(installdir)/WiredBot; \
chown $(WD_USER):$(WD_GROUP) $(installdir)/WiredBot; \
fi

$(INSTALL) -m 644 -o $(WD_USER) -g $(WD_GROUP) $(rundir)/wired.xml $(installdir)/
$(INSTALL) -m 755 -o $(WD_USER) -g $(WD_GROUP) $(rundir)/wired $(installdir)/
$(INSTALL) -m 755 -o $(WD_USER) -g $(WD_GROUP) $(rundir)/wiredctl $(installdir)/
Expand Down
227 changes: 179 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,40 @@ These are usually distributed with operating systems.

**Debian/Ubuntu**

sudo apt-get install -y build-essential autoconf git libsqlite3-dev libxml2-dev libssl-dev zlib1g-dev
sudo apt-get install -y build-essential autoconf screen git libsqlite3-dev libxml2-dev libssl-dev zlib1g-dev autotools-dev automake

**Archlinux**

sudo pacman -Sy base-devel autoconf screen git sqlite3 libxml2 zlib

**CentOS 7**

sudo yum -y install git libtool openssl-devel sqlite-devel.x86_64 libxml2-devel zlib-devel autoconf gcc make
sudo yum -y install screen git libtool openssl-devel sqlite-devel.x86_64 libxml2-devel zlib-devel autoconf gcc make

**CentOS 8 / Fedora 28/29/30/31 (and probably even older versions of Fedora)**

sudo yum -y install git libtool openssl-devel sqlite-devel libxml2-devel zlib-devel autoconf gcc make
sudo yum -y install screen git libtool openssl-devel sqlite-devel libxml2-devel zlib-devel autoconf gcc make

**openSUSE Leap 42.3 (and probably other Versions)**

sudo zypper install -t pattern devel_basis
sudo zypper install screen git sqlite3-devel libxml2-devel libz1 openssl-devel

### Getting started

Installing Wired Server from sources will be done using the Autotools standard (configure, make, make install).

##### 1. Get Wired Server sources via Terminal (git must be installed!):

git clone https://github.com/nark/wired wired
git clone https://github.com/ProfDrLuigi/wired wired

Then move to the `wired` directory:

cd wired/

Initialize and update submodules repositories:

git submodule update --init --recursive --remote

git clone https://github.com/ProfDrLuigi/libwired libwired
libwired/bootstrap

Then check that the `libwired` directory was not empty and `configure` file exists.
Expand All @@ -54,10 +61,14 @@ Then check that the `libwired` directory was not empty and `configure` file exis

During the configuration, scripts will check that your environment fills the requirements described at the top of this document. You will be warned if any of the required component is missing on your operating system.

To start configuration, use the following command:
To start configuration for Intel/AMD, use the following command:

./configure

To start configuration for arm64, use the following command:

./configure --build=aarch64 --host=aarch64

Wired Server is designed to be installed into `/usr/local` by default. To change this, run:

./configure --prefix=/path
Expand All @@ -73,6 +84,8 @@ If you installed OpenSSL in a non-standard path, use the following command examp

Use `./configure --help` in order to display more options.



##### 4. Compile source code:

On GNU-like unices, type:
Expand All @@ -96,65 +109,183 @@ Or, on BSD-like unices, type:

This will require write permissions to `/usr/local/`, or whatever directory you set as the prefix above. Depending of your OS setup, you may require to use `sudo`.

##### 6. Running Wired Server
### WiredBot: file announcements and local chat messages

To start an installed Wired server, run:
Wired Server includes a virtual chat user named **WiredBot**. It can announce
new files and folders from a watched directory and can accept chat messages
from local programs through a named pipe. Both inputs use the same configurable
name, status and icon and post to the public chat like a regular user.

/usr/local/wired/wiredctl start
#### Installed files

By default a user with the login "admin" and no password is created. Use Wired Client or Wire to connect to your newly installed Wired Server.
`make install` prepares these resources in the Wired installation directory:

### Running on Docker
* `robo.png` — the default WiredBot icon.
* `WiredBot` — a named pipe (FIFO), owned by the configured Wired user and
group with mode `0660`.

Pull and run the container:
Existing copies are preserved during updates. Installation stops with an error
instead of overwriting `WiredBot` if that path exists but is not a named pipe.

docker run --name wired -d -p 4871:4871 -v /path/to/yours/files:/files wired2/wired:2.5
The shipped configuration refers to both resources but keeps the bot disabled
until it is explicitly enabled:

* the `-p` option maps the container port (`4871`) to whatever the port you want to use on your host machine. If you want `wired` to be available on another you can use: `10000:4871` and Docker will translate it.
* the `-v` option maps items of the container file system with your local file system. You can change the first value of the pair to adjust to your server files configuration. Wired Server will look into the `/files` path of the container to index and server your files.
```ini
watch enabled = no
watch pipe = WiredBot
watch icon = robo.png
```

If you want Docker to start the container automatically for you, add the `--restart always` argument as follow:
#### Complete configuration example

docker run --name wired --restart always -d -p 4871:4871 -v /path/to/yours/files:/files wired2/wired:2.5
Add or edit the following settings in `<wired-root>/etc/wired.conf`:

Start/stop the container:
```ini
# Enable the virtual user, directory watcher and local message pipe.
watch enabled = yes

docker stop wired
docker start wired

Remove the container:
# Optional directory monitored recursively for new files and folders.
watch path = files/Uploads

docker rm wired

It could be useful to backup and restore container files such as `database.sqlite3` or `wired.conf`. You can do that do using the `docker cp` command.

From container to host:

docker cp wired:/user/local/wired/database.sqlite3 /path/to/your/database.sqlite3
# Message used for file and folder announcements.
watch message = New stuff has arrived: $FILE ($SIZE)

From host to container:
# Local FIFO used by scripts and other local processes.
watch pipe = WiredBot

docker cp /path/to/your/database.sqlite3 wired:/user/local/wired/database.sqlite3

Build the image locally:
# Identity shown in the public chat user list.
watch name = WiredBot
watch status = Watching for new files
watch icon = robo.png
```

cd wired/
docker build --tag wired:2.5 .

Tag the image:

docker tag <image_id> wired2/wired:2.5

Push to Docker Hub:

docker push wired2/wired:2.5
Relative paths are resolved from the Wired installation directory. Absolute
paths may also be used. After changing the configuration, validate and reload
it without restarting the server:

### Get More
```sh
<wired-root>/wiredctl configtest
<wired-root>/wiredctl reload
```

If you are interested in the Wired project, check the Website at [http://wired.read-write.fr/](http://wired.read-write.fr)
For example, with Wired installed in `/opt/wired`:

### Troubleshootings
```sh
/opt/wired/wiredctl configtest
/opt/wired/wiredctl reload
```

#### Directory watcher behavior

When `watch path` is configured, the server scans that directory recursively:

* Items already present when the server starts or reloads its configuration
form the initial baseline and are not announced.
* A new file is announced only after its size and modification time have
stopped changing.
* A newly copied directory is announced once as a directory. Files and nested
directories already arriving inside it are added to the baseline silently
and are not announced individually.
* Files created later inside an already known directory are announced normally.
* Invisible paths are ignored.

The announcement template supports these placeholders:

* `$FILE` — path relative to `watch path`.
* `$SIZE` — formatted file size; for a directory this becomes `folder`.

Examples:

```ini
watch message = New stuff has arrived: $FILE
```

```ini
watch message = New item: $FILE ($SIZE)
```

#### Sending messages from Debian programs

Every newline-terminated line written to the FIFO becomes one public-chat
message from WiredBot. With Wired installed in `/opt/wired`, use:

```sh
echo "Hello World." > /opt/wired/WiredBot
```

Multiple lines produce multiple chat messages:

```sh
printf 'First message\nSecond message\n' > /opt/wired/WiredBot
```

Programs running as another Unix user require write permission through the
FIFO's owner or group. Prefer adding that user to the configured Wired group
instead of making the pipe world-writable.

This implementation of the Wired 2.0 protocol is not compliant with the version of the protocol distributed by Zanka Software, for several deep technical reasons.
Messages may contain HTML supported by Wired Client. Two convenience aliases
are also accepted:

* `<n>...</n>` creates a neutral message container.
* `<bold>...</bold>` renders its contents in bold.

For example:

```sh
echo '<n>☹️ <bold>Hello</bold></n>' > /opt/wired/WiredBot
```

This is delivered as:

```html
<span>☹️ <strong>Hello</strong></span>
```

HTML display must be enabled in the receiving Wired Client. Because FIFO input
may contain HTML, grant write access only to trusted local users and services.
Messages larger than 64 KiB are discarded.

#### Changing the bot identity

The virtual user's appearance is controlled entirely through `wired.conf`:

```ini
watch name = Wired Server
watch status = File notifications
watch icon = robo.png
```

The icon may use a relative path below the Wired installation directory or an
absolute path. Identity changes take effect after `wiredctl reload` and are
broadcast to connected clients.

#### Disabling WiredBot

To remove the virtual user from the public chat and stop both the directory
watcher and FIFO processing, set:

```ini
watch enabled = no
```

Then reload the configuration. The FIFO may remain in the installation
directory so it is immediately available the next time the bot is enabled.

##### 6. Running Wired Server

By default a user with the login "admin" and no password is created. Use Wired Client or Wire to connect to your newly installed Wired Server.

Wired is compiled as foreground Task in Debug mode. Thats why you nee to run it in a screen-Session.
If you run it in Daemon Mode your CPU will going crazy after some time (100% usage).

To start an installed Wired server, run:

./wiredctl start

### Get More

If you are interested in the Wired project, check the Website at [https://wired.read-write.fr/](https://wired.read-write.fr)

### Troubleshootings

This implementation of the Wired 2.0/2.5 protocol is not compliant with the version of the protocol distributed by Zanka Software, for several deep technical reasons.
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
#define WD_VERSION "2.5"

/* Subversion revision */
#define WI_REVISION "2.5.2"
#define WI_REVISION "2.5.3"

/* SQLite does not support backup */
#define WI_SQLITE_SUPPORTS_BACKUP 1
Expand Down
Loading