websoft9/install/install_plugins.sh

83 lines
2.2 KiB
Bash
Raw Normal View History

2023-09-19 10:12:37 +00:00
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
2023-09-19 09:44:20 +00:00
2023-09-19 11:55:23 +00:00
2023-09-25 09:53:21 +00:00
# Command-line options
# ==========================================================
#
# --channel <release|dev>
# Use the --channel option to install a release(production) or dev distribution. default is release, for example:
#
# $ sudo sh install.sh --channel release
#
# ==============================================================================
# get input and define vars
while [[ $# -gt 0 ]]; do
case $1 in
--channel)
channel="$2"
shift 2
;;
*)
shift
;;
esac
done
2023-09-19 09:44:20 +00:00
2023-09-26 10:21:45 +00:00
# channel,source_github_pages,install_path from install.sh priority
2023-09-25 09:53:21 +00:00
if [ -z "$channel" ]; then
channel="release"
fi
2023-09-19 09:44:20 +00:00
2023-09-25 09:53:21 +00:00
if [ -z "$source_github_pages" ]; then
source_github_pages="https://websoft9.github.io/websoft9"
fi
2023-09-19 09:44:20 +00:00
2023-09-25 09:53:21 +00:00
if [ -z "$install_path" ]; then
install_path="/data/websoft9/source"
fi
2023-09-19 09:44:20 +00:00
2023-10-06 12:34:28 +00:00
echo -e "\n\n-------- Plugins --------"
2023-09-25 09:53:21 +00:00
echo "Your installation parameters are as follows: "
echo "--channel: $channel"
2023-09-27 07:28:02 +00:00
echo "--install_path: $install_path"
2023-09-19 09:44:20 +00:00
2024-09-05 01:04:28 +00:00
artifact_url="https://artifact.websoft9.com/$channel/websoft9/plugin"
2023-09-26 10:21:45 +00:00
echo_prefix_plugins=$'\n[Plugins] - '
versions_local_file="$install_path/version.json"
versions_url="$source_github_pages/version.json"
file_suffix=".zip"
plugin_path="/usr/share/cockpit"
2023-11-08 03:52:21 +00:00
2023-10-06 12:34:28 +00:00
echo "$echo_prefix_plugins Starting download plugin and update it"
2023-11-14 08:15:10 +00:00
if [ -f "$versions_local_file" ]; then
echo "File $versions_local_file exists."
else
echo "File $versions_local_file does not exist. Downloading from $versions_url"
wget -q $versions_url -O $versions_local_file
fi
2023-09-26 10:21:45 +00:00
2023-11-14 08:15:10 +00:00
plugins=$(jq -c '.plugins' $versions_local_file)
if [ -z "$plugins" ]; then
echo "No plugins found in $versions_local_file"
exit 1
fi
2023-09-26 10:21:45 +00:00
2023-11-14 08:15:10 +00:00
for key in $(jq -r '.plugins | keys[]' $versions_local_file); do
version=$(jq -r ".plugins.${key}" $versions_local_file)
file_url=$artifact_url/$key/$key-$version$file_suffix
file_name=$key-$version$file_suffix
echo "Download from $file_url"
wget -q $file_url -O $file_name
unzip -oq $file_name -d $plugin_path
2023-11-15 02:21:16 +00:00
rm -rf $file_name
2023-11-14 08:15:10 +00:00
done
2023-09-26 10:21:45 +00:00
2023-11-01 09:39:12 +00:00
find /usr/share/cockpit -type f -name "*.py3" -exec chmod +x {} \;
2023-09-26 10:21:45 +00:00
echo "Plugins install successfully..."