chore: organize codes
This commit is contained in:
parent
5fe0e8ace3
commit
6223eb9b19
2 changed files with 103 additions and 40 deletions
136
install.sh
136
install.sh
|
@ -1,40 +1,104 @@
|
|||
#!/bin/bash
|
||||
# installation script
|
||||
CUR_HOME=$(compgen -f -- /home/bot*)
|
||||
cd "$CUR_HOME" || exit
|
||||
mkdir tmp_install
|
||||
cd tmp_install || exit
|
||||
if [ "$1" == 1 ]; then
|
||||
wget http://sertifika.meb.gov.tr/MEB_SERTIFIKASI.cer
|
||||
openssl x509 -inform DER -in MEB_SERTIFIKASI.cer -out MEB_SERTIFIKASI.crt
|
||||
sudo cp MEB_SERTIFIKASI.crt /usr/local/share/ca-certificates/
|
||||
###########################################################
|
||||
# Install prerequisites, necessary applications/tools and #
|
||||
# set up configs for end user in iflbot computers #
|
||||
# #
|
||||
# Author: Aliberk Sandıkçı #
|
||||
# School: Izmir Science High School #
|
||||
###########################################################
|
||||
|
||||
# Error Handling
|
||||
set -e
|
||||
trap _cleanup EXIT HUP INT TERM
|
||||
|
||||
# Variables
|
||||
VERSION="0.0.3"
|
||||
# user=$([ -n "$SUDO_USER" ] && echo "$SUDO_USER" || echo "$USER")
|
||||
# home="/home/${user}"
|
||||
temp_file="$(mktemp -u)"
|
||||
temp_dir="$(mktemp -d)"
|
||||
repo_tag="main"
|
||||
repo_dest="https://github.com/asandikci/iflbot-setup"
|
||||
repo_name="iflbot-setup"
|
||||
src_dir="$temp_dir/$repo_name-$repo_tag/src/"
|
||||
|
||||
cat <<-EOF
|
||||
/\$\$\$\$\$\$ /\$\$\$\$\$\$\$\$ /\$\$ /\$\$\$\$\$\$\$ /\$\$\$\$\$\$ /\$\$\$\$\$\$\$\$
|
||||
|_ \$\$_/| \$\$_____/| \$\$ | \$\$__ \$\$ /\$\$__ \$\$|__ \$\$__/
|
||||
| \$\$ | \$\$ | \$\$ | \$\$ \ \$\$| \$\$ \ \$\$ | \$\$
|
||||
| \$\$ | \$\$\$\$\$ | \$\$ | \$\$\$\$\$\$\$ | \$\$ | \$\$ | \$\$
|
||||
| \$\$ | \$\$__/ | \$\$ | \$\$__ \$\$| \$\$ | \$\$ | \$\$
|
||||
| \$\$ | \$\$ | \$\$ | \$\$ \ \$\$| \$\$ | \$\$ | \$\$
|
||||
/\$\$\$\$\$\$| \$\$ | \$\$\$\$\$\$\$\$| \$\$\$\$\$\$\$/| \$\$\$\$\$\$/ | \$\$
|
||||
|______/|__/ |________/|_______/ \______/ |__/
|
||||
LAB COMPUTER SETUP SCRIPT - VERSION $VERSION
|
||||
EOF
|
||||
|
||||
# FUNCTIONS
|
||||
|
||||
#run with sudo if $2 is not executable
|
||||
_sudo() {
|
||||
if [ -x "$2" ]; then
|
||||
"$@"
|
||||
else
|
||||
sudo "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
#download and install certificate
|
||||
_certificate() {
|
||||
echo "Dowloading MEB certificate ..."
|
||||
timeout 10 wget -qO "$temp_file" "http://sertifika.meb.gov.tr/MEB_SERTIFIKASI.cer" || (echo -e "There was an error with the dowloading certificate\nAborting..." && return 1)
|
||||
|
||||
echo "Converting .cer file to .crt file ..."
|
||||
openssl x509 -inform DER -in "$temp_file" -out "$temp_file"
|
||||
|
||||
echo "Moving certificate to /usr/local/share/ca-certificates/"
|
||||
sudo mv "$temp_file" "/usr/local/share/ca-certificates/MEB_SERTIFIKASI.crt"
|
||||
|
||||
echo "Giving necessary file permission"
|
||||
sudo chmod 644 /usr/local/share/ca-certificates/MEB_SERTIFIKASI.crt
|
||||
|
||||
echo "Updating certificate configs ..."
|
||||
sudo update-ca-certificates
|
||||
}
|
||||
|
||||
#download from GitHub
|
||||
_download() {
|
||||
echo "Getting the latest version from GitHub ..."
|
||||
wget -O "$temp_file" "${repo_dest}/archive/${repo_tag}.tar.gz"
|
||||
|
||||
echo "Unpacking archive to $temp_dir ..."
|
||||
tar -xzf "$temp_file" -C "$temp_dir"
|
||||
}
|
||||
|
||||
#install packages
|
||||
_install() {
|
||||
if [ -f "$src_dir/prerequisites.sh" ]; then
|
||||
echo "Installing prerequisites ..."
|
||||
_sudo bash "$src_dir/prerequisites.sh"
|
||||
fi
|
||||
if [ -f "$src_dir/applications.sh" ]; then
|
||||
echo "Installing applications ..."
|
||||
_sudo bash "$src_dir/applications.sh"
|
||||
fi
|
||||
if [ -f "$src_dir/config.sh" ]; then
|
||||
echo "Configuring settings ..."
|
||||
_sudo bash "$src_dir/config.sh"
|
||||
fi
|
||||
}
|
||||
|
||||
#clear cache, delete temporary files
|
||||
_cleanup() {
|
||||
echo "Clearing cache ..."
|
||||
rm -rf "$temp_file" "$temp_dir"
|
||||
echo "Done!"
|
||||
}
|
||||
|
||||
# Main
|
||||
if [[ "$1" == "cert" ]]; then
|
||||
_certificate
|
||||
fi
|
||||
if [ "$1" == 2 ]; then
|
||||
sudo cp "$CUR_HOME"/Desktop/MEB_SERTIFIKASI.crt /usr/local/share/ca-certificates/
|
||||
sudo chmod 644 /usr/local/share/ca-certificates/MEB_SERTIFIKASI.crt
|
||||
sudo update-ca-certificates
|
||||
fi
|
||||
sudo apt install curl -y
|
||||
wget https://github.com/asandikci/iflbot-setup/archive/refs/heads/main.tar.gz
|
||||
tar -xzvf main.tar.gz
|
||||
cd iflbot-setup-main || exit
|
||||
cd src || exit
|
||||
ls
|
||||
chmod +x prerequisites.sh
|
||||
chmod +x applications.sh
|
||||
bash prerequisites.sh
|
||||
bash applications.sh
|
||||
bash prerequisites.sh
|
||||
EX_PATH="$CUR_HOME"/.vscode/extensions/
|
||||
mkdir -p "$EX_PATH"
|
||||
mkdir -p "$CUR_HOME/Desktop/Codes/"
|
||||
cp main.c "$CUR_HOME/Desktop/Codes/"
|
||||
cp -r danielpinto8zz6.c-cpp-compile-run-1.0.18 "$EX_PATH"
|
||||
cd "$CUR_HOME" || exit
|
||||
rm -r tmp_install
|
||||
sudo apt-get install gcc -y
|
||||
echo "INSTALLATION SUCCESSFULLY COMPLETED"
|
||||
sleep 50
|
||||
reboot
|
||||
_download
|
||||
_install
|
||||
_reboot
|
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
# prerequisites
|
||||
|
||||
sudo apt-get install apt-transport-https -y
|
||||
sudo apt install software-properties-common wget -y
|
||||
sudo apt install gcc -y
|
||||
sudo apt install build-essential -y
|
||||
sudo apt-get install curl wget apt-transport-https -y
|
||||
sudo apt install software-properties-common -y
|
||||
sudo apt install gcc build-essential cmake make g++ -y
|
Loading…
Reference in a new issue