Skip to content

Instantly share code, notes, and snippets.

@yeungon
Last active September 19, 2023 07:01
Show Gist options
  • Save yeungon/7ac3c975917e07b70e8eeee5027fce46 to your computer and use it in GitHub Desktop.
Save yeungon/7ac3c975917e07b70e8eeee5027fce46 to your computer and use it in GitHub Desktop.
#!/bin/bash
#######################################################
# Kiwiscript Installer v0.0.1
# To install Kiwiscript type:
# curl -sLO https://raw.githubusercontent.com/yeungon/kiwiscript/main/install && chmod +x install && sudo bash install
#######################################################
LANG=en_US.UTF-8
#sudo -s
# Check for sudo/root privileges
if [[ $(whoami) != "root" ]]; then
echo "$(tput setaf 1)You should install kiwiscript as root or using sudo.$(tput sgr0)"
exit 1
fi
# Check the current distro
readonly distro=`echo $(grep -oP 'PRETTY_NAME="\K[^"]+' /etc/os-release | cut -f1 -d' ')`
echo "Your current Kernel: ${uname -r }";
echo "Your current Linux distro: ${distro}";
if [[ $(distro) != "Ubuntu" ]]; then
echo "$(tput setaf 1)The current verion of kiwiscript only works on Ubuntu.$(tput sgr0)"
exit 1
fi
function check_file_availability() {
if [ -e "$1" ]; then
return 0 # File exists, return true (0)
else
return 1 # File does not exist, return false (non-zero)
fi
}
function BaseCentos(){
sudo yum install wget curl zip -y
}
function BaseUbuntu(){
sudo apt-get install wget curl zip -y
}
# Install the base system for the specified distribution.
function installBase(){
if [ "$distro" == "Ubuntu" ]; then
BaseUbuntu
elif [ "$distro" == "AlmaLinux" ] || [ "$distro" == "Centos" ] || [ "$distro" == "RockyLinux" ]; then
BaseCentos
fi
}
function getBinary() {
wget https://tudien.net/kiwi
}
#bug: rm: cannot remove 'kiwi': No such file or directory
function removeFile() {
cd /usr/bin
if check_file_availability "$1"; then
sudo rm "$1"
fi
}
function moveFile() {
sudo mv -v kiwi /usr/bin
sudo chmod 755 /usr/bin/kiwi
}
function run(){
echo "kiwiscript has been successfully installed on your VPS!"
kiwi
}
installBase
removeFile "kiwi"
getBinary
moveFile
run
rm install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment