#!/bin/bash

# Created by jiaqiang.ye@lnxall.com
# Install luacheck.lua into /opt/Lua51
# 2026/04/28

if [ -f /opt/Lua51/bin/luacheck.lua ] ; then
	echo "Warning, luacheck.lua already installed, skipped"
	exit 0
fi

if [ ${UID} -ne 0 ] ; then
	echo "Error, run again as root."
	exit 1
fi

if [ ! -d /opt/Lua51 ] ; then
	echo "Error, directory not found: \`/opt/Lua51"
	exit 2
fi

if [ ! -f luacheck-opt-Lua51.tar.gz ] ; then
	echo "Error, source tarball not found: luacheck-opt-Lua51.tar.gz"
	exit 3
fi

echo "Extracting luacheck-opt-Lua51.tar.gz to \`/opt/Lua51 ..."
tar -zxf luacheck-opt-Lua51.tar.gz -C /opt/Lua51
exit $?
