Skip to content

Commit

Permalink
Add build script
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszmitka committed Jun 2, 2020
1 parent e0f53b7 commit 47f1f3b
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/husarion_motd
nimcache/
package_dir
husarion-motd-*
.vscode
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# husarion-motd

Welcome message for Linux-based Husarion devices

## Building

To build the package you need `nim`:

```
sudo apt install nim
```

You can use `build.sh` script to preapare `.deb` package:

```
./build.sh
```

Script will create a `.deb` package named according to pattern: `husarion-motd-VERSION-ARCH.deb`

Install it with:

```
sudo dpkg -i husarion-motd-VERSION-ARCH.deb
```

57 changes: 57 additions & 0 deletions build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

ARCHITECTURE=$(uname -m)
VERSION='1.0.2'

if [ $ARCHITECTURE = "x86_64" ]
then
ARCH='amd64'
elif [[ $ARCHITECTURE = 'armv7l' ]]
then
ARCH='armhf'
else
echo 'Unsupported architecture'
exit 1
fi

rm -rf package_dir
mkdir package_dir
mkdir package_dir/DEBIAN
mkdir package_dir/etc
mkdir package_dir/etc/profile.d/
mkdir package_dir/usr
mkdir package_dir/usr/bin

echo "Package: husarion-motd
Version: $VERSION
Section: custom
Priority: optional
Architecture: $ARCH
Essential: no
Installed-Size: 1024
Maintainer: Husarion <support@husarion.com>
Description: Welcome message for Linux-based Husarion devices" > package_dir/DEBIAN/control

echo "#!/bin/sh
set -e
if [ -e /etc/motd -a ! -e /etc/motd.old ]; then
mv /etc/motd /etc/motd.old
touch /etc/motd
fi
chmod -x /etc/update-motd.d/*" > package_dir/DEBIAN/postinst
chmod a+x package_dir/DEBIAN/postinst

cp -a husarion-motd.sh package_dir/etc/profile.d/husarion-motd.sh


if [ $ARCH = 'amd64' ]
then
nim compile --define:pro husarion_motd.nim
elif [ $ARCH = 'armhf' ]
then
nim compile husarion_motd.nim
fi

mv husarion_motd package_dir/usr/bin/husarion-motd

dpkg-deb --build package_dir husarion-motd-$VERSION-$ARCH.deb
29 changes: 20 additions & 9 deletions husarion_motd.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,29 @@ const logo = """
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"""

const title = """
_____ ____ _____ ______ ___ _____ ____ _____
/ ____/ __ \| __ \| ____|__ \ | __ \ / __ \ / ____|
| | | | | | |__) | |__ ) |_____| |__) | | | | (___
| | | | | | _ /| __| / /______| _ /| | | |\___ \
| |___| |__| | | \ \| |____ / /_ | | \ \| |__| |____) |
\_____\____/|_| \_\______|____| |_| \_\\____/|_____/
when not defined(pro):
const title = """
_____ ____ _____ _ _ ___ ___
| __ \ / __ \ / ____|| | | | |__ \ / _ \
| |__) || | | || (___ | |__ ___ | |_ ) | | | | |
| _ / | | | | \___ \ | '_ \ / _ \ | __| / / | | | |
| | \ \ | |__| | ____) || |_) || (_) || |_ / /_ _| |_| |
|_| \_\ \____/ |_____/ |_.__/ \___/ \__| |____|(_)\___/
"""

const baseInfoText = """Documentation: https://docs.husarion.com
Remote access: https://cloud.husarion.com"""
when defined(pro):
const title = """
_____ ____ _____ _ _ ___ ___ _____ _____ ____
| __ \ / __ \ / ____|| | | | |__ \ / _ \ | __ \ | __ \ / __ \
| |__) || | | || (___ | |__ ___ | |_ ) | | | | | | |__) || |__) || | | |
| _ / | | | | \___ \ | '_ \ / _ \ | __| / / | | | | | ___/ | _ / | | | |
| | \ \ | |__| | ____) || |_) || (_) || |_ / /_ _| |_| | | | | | \ \ | |__| |
|_| \_\ \____/ |_____/ |_.__/ \___/ \__| |____|(_)\___/ |_| |_| \_\ \____/
"""

const baseInfoText = """Documentation: https://husarion.com/manuals/"""

const
redFont = "\x1b[31m"
Expand Down

0 comments on commit 47f1f3b

Please sign in to comment.