lets just call this a git init okay?
This commit is contained in:
parent
f6b0821ad5
commit
4fc74ecbe3
29
REDME.md
29
REDME.md
@ -2,22 +2,31 @@
|
||||
Simple Bash application installer.
|
||||
|
||||
## Applications & Software
|
||||
* Visual Studio Code (TO-DO)
|
||||
* Node (TO-DO)
|
||||
* Java (TO-DO)
|
||||
* Android Studio (TO-DO)
|
||||
* Discord (TO-DO)
|
||||
* OBS (TO-DO)
|
||||
* Bootstrap Studio
|
||||
* Chromium (TO-DO)
|
||||
* Defold (TO-DO)
|
||||
* Spotify (TO-DO)
|
||||
* Slack (TO-DO)
|
||||
* ZSH (TO-DO)
|
||||
* Discord (TO-DO)
|
||||
* Docker (TO-DO)
|
||||
* Firefox
|
||||
* Gcc
|
||||
* Git
|
||||
* Node
|
||||
* NordVPN
|
||||
* OBS
|
||||
* Python (TO-DO)
|
||||
* Yarn
|
||||
* Open-jdk
|
||||
* Slack
|
||||
* Spotify
|
||||
* Visual Studio Code
|
||||
* Xampp (TO-DO)
|
||||
* ZSH (TO-DO)
|
||||
* Missing any applications or software? Feel free to leave an issue behind or create a merge request with the created files :)
|
||||
|
||||
## Create
|
||||
Add file name to array in install.sh file
|
||||
## TO-DO
|
||||
Name change BashInstaller -> Installify
|
||||
See applications and software tab
|
||||
|
||||
|
||||
|
266
install.sh
266
install.sh
@ -1,45 +1,263 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
# set -e
|
||||
set -u
|
||||
|
||||
# FUNCTIONS
|
||||
create_app_folder() {
|
||||
# create at home dir
|
||||
cd $homedir
|
||||
|
||||
if [[ ! -d "Applications" ]]; then
|
||||
sudo -u $SUDO_USER mkdir Applications
|
||||
fi
|
||||
|
||||
myfunc() {
|
||||
local myresult='some value'
|
||||
echo $myresult
|
||||
# go back to install folder
|
||||
cd $dir
|
||||
}
|
||||
|
||||
result="$(myfunc)"
|
||||
zsh_prompt() {
|
||||
# selection menu for zsh
|
||||
printf %s "$YELLOW"
|
||||
|
||||
deleteOption=""
|
||||
echo "Do you want Oh-My-ZSH as terminal extension?"
|
||||
echo "To use 'Oh-My-ZSH' enter 'y' to to continue in bash enter 'n'"
|
||||
read deleteOption
|
||||
|
||||
# check for valid input
|
||||
while [ ${deleteOption,,} != "y" ] && [ ${deleteOption,,} != "n" ]; do
|
||||
echo "Invalid input. Please press 'y' or 'n'"
|
||||
read deleteOption
|
||||
done
|
||||
|
||||
printf %s "$RESET"
|
||||
|
||||
# run option
|
||||
if [[ ${deleteOption,,} = "n" ]]; then
|
||||
return
|
||||
elif [[ ${deleteOption,,} = "y" ]]; then
|
||||
echo "nice choice lets use zsh"
|
||||
fi
|
||||
}
|
||||
|
||||
get_files() {
|
||||
cd Applications
|
||||
local -n arr=$1
|
||||
local FILES=(one two)
|
||||
|
||||
for file in "$PWD"/*; do
|
||||
if [[ $file == ./install.sh ]]; then
|
||||
echo "das"
|
||||
elif [[ $file == *.sh ]]; then
|
||||
# Create temp place where files will be stored
|
||||
cd src/applications
|
||||
> ../temp/installations.txt
|
||||
|
||||
# File info
|
||||
applications=""
|
||||
counter=0
|
||||
|
||||
# Write every file name into installations
|
||||
for file in *; do
|
||||
# Every .sh file in application folder will be noted in installations.txt
|
||||
if [[ $file == *.sh ]]; then
|
||||
counter=$(( $counter + 1 ))
|
||||
echo "[$counter] ${file%.*}" >> ../temp/installations.txt
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
select_files() {
|
||||
printf %s "$YELLOW"
|
||||
# Show all the options
|
||||
cd ../temp
|
||||
echo "The following items will be installed."
|
||||
cat installations.txt
|
||||
|
||||
printf %s "$RESET"
|
||||
|
||||
# Remove installations from file
|
||||
echo
|
||||
while read -p "${YELLOW}Select the number of the item you don't want to install (select '0' to continue): " input; do
|
||||
|
||||
# Restart loop if wrong character is used
|
||||
if [[ -n ${input//[0-9]/} ]]; then
|
||||
echo "Please enter a valid number!"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Break the loop on input
|
||||
if [[ $input == "0" || $input == "" ]]; then
|
||||
clear
|
||||
break
|
||||
else
|
||||
|
||||
# If pattern exist remove line
|
||||
if grep -wq "$input" "installations.txt"; then
|
||||
|
||||
# get the full text
|
||||
a="$(grep -F [$input] installations.txt)"
|
||||
|
||||
# reverse and remove full text
|
||||
grep -Fv "$a" installations.txt > filename2; mv filename2 installations.txt
|
||||
else
|
||||
echo "Please try again"
|
||||
fi
|
||||
|
||||
clear
|
||||
print_logo
|
||||
|
||||
printf %s "$YELLOW"
|
||||
echo "The following items will be installed."
|
||||
cat installations.txt
|
||||
echo
|
||||
printf %s "$RESET"
|
||||
|
||||
arr+=(${file##*/})
|
||||
fi
|
||||
done
|
||||
|
||||
echo ${FILES[@]}
|
||||
printf %s "$RESET"
|
||||
# remove all numbers from items
|
||||
sed -i 's/[^ ]* //' installations.txt
|
||||
}
|
||||
# https://stackoverflow.com/questions/10582763/how-to-return-an-array-in-bash-without-using-globals
|
||||
# get_files()
|
||||
array=()
|
||||
|
||||
get_files array
|
||||
# VAR+=("$(get_files)")
|
||||
install_files() {
|
||||
# Check if debug is activated
|
||||
if $debug; then
|
||||
while read line; do
|
||||
|
||||
#Reading each line and execute file
|
||||
if ! [ -x "$(command -v $line)" ]; then
|
||||
sh ../applications/$line.sh
|
||||
else
|
||||
echo "$line is already installed"
|
||||
fi
|
||||
|
||||
# echo "${VAR[-1]}"
|
||||
done < "installations.txt"
|
||||
else
|
||||
# set standard info
|
||||
source ./../services/loadbar.sh
|
||||
start=1
|
||||
end=100
|
||||
amount="$(wc -l < installations.txt)"
|
||||
amount=$(($end / $amount))
|
||||
|
||||
for i in "${arr[@]}"; do
|
||||
echo $i
|
||||
done
|
||||
# set design
|
||||
print_logo
|
||||
|
||||
printf %s "$YELLOW"
|
||||
echo "The following items are going to be installed:"
|
||||
cat installations.txt
|
||||
echo ""
|
||||
printf %s "$RESET"
|
||||
|
||||
while read line; do
|
||||
printf %s "$YELLOW"
|
||||
|
||||
ProgressBar ${start} ${end} ${line}
|
||||
#Reading each line and execute file
|
||||
if ! [ -x "$(command -v $line)" ]; then
|
||||
sh ../applications/$line.sh >> /dev/null 2>&1
|
||||
fi
|
||||
|
||||
# update progressbar
|
||||
reach=$(( $start + $amount ))
|
||||
for number in $(seq ${start} ${reach}); do
|
||||
ProgressBar ${number} ${end} ${line}
|
||||
sleep 0.02
|
||||
done
|
||||
printf %s "$RESET"
|
||||
start=$reach
|
||||
|
||||
done < "installations.txt"
|
||||
|
||||
# Completing
|
||||
if [[ $start != 100 ]]; then
|
||||
for number in $(seq ${start} 100); do
|
||||
ProgressBar ${number} ${end} "..."
|
||||
sleep 0.02
|
||||
done
|
||||
fi
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
check_arguments() {
|
||||
if [[ $1 = "-h" || $1 = "-help" ]]; then
|
||||
print_logo
|
||||
print_help
|
||||
exit 1
|
||||
elif [[ $1 = "-v" || $1 = "-version" ]]; then
|
||||
print_version
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_sudo_arguments() {
|
||||
check_arguments $@
|
||||
|
||||
if [[ $1 = "-d" || $1 = "-debug" ]]; then
|
||||
debug=true
|
||||
main
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
# check if the computer has a stable connections
|
||||
source ./src/services/connection.sh
|
||||
check_connection
|
||||
|
||||
# Create applications folder
|
||||
create_app_folder
|
||||
|
||||
# Print the logo
|
||||
clear
|
||||
print_logo
|
||||
|
||||
# ZSH prompt
|
||||
zsh_prompt
|
||||
|
||||
# Print the logo
|
||||
clear
|
||||
print_logo
|
||||
|
||||
# create file with all items
|
||||
get_files
|
||||
|
||||
# sort the file with the items
|
||||
select_files
|
||||
|
||||
# install the selected files
|
||||
install_files
|
||||
|
||||
# remove all files in temp
|
||||
cd ~
|
||||
cd $dir
|
||||
cd src
|
||||
rm temp/*
|
||||
}
|
||||
|
||||
# PROGRAM BODY
|
||||
# Safe important paths
|
||||
dir="$(pwd)"
|
||||
|
||||
# Make sure the code is runned in the right way
|
||||
if [[ `basename "$dir"` != "BashInstaller" ]]; then
|
||||
echo "Please run this script in the Bashinstaller folder."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# add help.sh
|
||||
source ./src/services/help.sh
|
||||
setup_color
|
||||
|
||||
if [[ $EUID != 0 ]]; then
|
||||
check_arguments $@
|
||||
echo "Please run this script with sudo. Run it like this:"
|
||||
echo "sudo ./install.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Safe important variables
|
||||
homedir="$(getent passwd $SUDO_USER | cut -d: -f6)"
|
||||
debug=false
|
||||
|
||||
# run the program
|
||||
if [ $# -eq 0 ]; then
|
||||
main
|
||||
else
|
||||
check_sudo_arguments $@
|
||||
fi
|
2
src/Oh-My-ZSH(TO-DO).sh
Normal file
2
src/Oh-My-ZSH(TO-DO).sh
Normal file
@ -0,0 +1,2 @@
|
||||
sudo apt install zsh -y
|
||||
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" -y
|
37
src/applications/BootstrapStudio.sh
Executable file
37
src/applications/BootstrapStudio.sh
Executable file
@ -0,0 +1,37 @@
|
||||
# Get the full html and get the link of the button
|
||||
wget https://bootstrapstudio.io/download
|
||||
latestversionimage="$(grep -w 'data-linux="' "download")"
|
||||
latestversionsh="$(grep -w 'data-linux-install="' "download")"
|
||||
|
||||
# remove useless stuff of the link
|
||||
latestversionimage=${latestversionimage#*'data-linux="'}
|
||||
latestversionimage=${latestversionimage%'"'*}
|
||||
|
||||
# remove useless stuff of the link
|
||||
latestversionsh=${latestversionsh#*'"'}
|
||||
latestversionsh=${latestversionsh%'"'*}
|
||||
|
||||
# Safe the path
|
||||
curdir="$(pwd)"
|
||||
homedir="$(getent passwd $SUDO_USER | cut -d: -f6)"
|
||||
|
||||
# go to app folder to safe the files
|
||||
cd $homedir
|
||||
cd Applications
|
||||
|
||||
sudo -u $SUDO_USER mkdir BootstrapStudio
|
||||
cd BootstrapStudio
|
||||
|
||||
# get images
|
||||
sudo -u $SUDO_USER wget https://bootstrapstudio.io/$latestversionimage
|
||||
sudo -u $SUDO_USER wget https://bootstrapstudio.io/$latestversionsh
|
||||
|
||||
# downloadd app
|
||||
echo "y" | sudo -u $SUDO_USER bash launcher.sh
|
||||
|
||||
# remove unnesesary files
|
||||
rm launcher.sh
|
||||
|
||||
# get back to main folder
|
||||
cd ~
|
||||
cd $curdir
|
2
src/applications/Firefox.sh
Normal file
2
src/applications/Firefox.sh
Normal file
@ -0,0 +1,2 @@
|
||||
sudo apt-get update
|
||||
sudo apt install firefox
|
2
src/applications/Git.sh
Executable file
2
src/applications/Git.sh
Executable file
@ -0,0 +1,2 @@
|
||||
sudo apt-get update
|
||||
sudo apt-get install git
|
3
src/applications/Node.sh
Normal file
3
src/applications/Node.sh
Normal file
@ -0,0 +1,3 @@
|
||||
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
|
||||
./../applications/gcc.sh
|
||||
sudo apt-get install -y nodejs
|
4
src/applications/NordVPN.sh
Normal file
4
src/applications/NordVPN.sh
Normal file
@ -0,0 +1,4 @@
|
||||
wget https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb
|
||||
sudo apt-get install ./nordvpn-release_1.0.0_all.deb
|
||||
sudo apt-get update
|
||||
sudo apt install nordvpn
|
2
src/applications/OBS.sh
Normal file
2
src/applications/OBS.sh
Normal file
@ -0,0 +1,2 @@
|
||||
sudo apt update
|
||||
sudo apt install obs-studio
|
3
src/applications/Slack.sh
Normal file
3
src/applications/Slack.sh
Normal file
@ -0,0 +1,3 @@
|
||||
sudo snap install slack --classic
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade slack-desktop
|
10
src/applications/VSCode.sh
Normal file
10
src/applications/VSCode.sh
Normal file
@ -0,0 +1,10 @@
|
||||
# get package
|
||||
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
|
||||
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
|
||||
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
|
||||
rm -f packages.microsoft.gpg
|
||||
|
||||
# install package
|
||||
sudo apt install apt-transport-https
|
||||
sudo apt update
|
||||
sudo apt install code
|
3
src/applications/Yarn.sh
Normal file
3
src/applications/Yarn.sh
Normal file
@ -0,0 +1,3 @@
|
||||
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
||||
sudo apt-get update && sudo apt-get install yarn
|
1
src/applications/gcc.sh
Normal file
1
src/applications/gcc.sh
Normal file
@ -0,0 +1 @@
|
||||
sudo apt-get install gcc g++ make
|
2
src/applications/openjdk.sh
Normal file
2
src/applications/openjdk.sh
Normal file
@ -0,0 +1,2 @@
|
||||
sudo apt update
|
||||
sudo apt install default-jdk
|
3
src/applications/spotify.sh
Normal file
3
src/applications/spotify.sh
Normal file
@ -0,0 +1,3 @@
|
||||
curl -sS https://download.spotify.com/debian/pubkey_0D811D58.gpg | sudo apt-key add -
|
||||
echo "deb http://repository.spotify.com stable non-free" | sudo tee /etc/apt/sources.list.d/spotify.list
|
||||
sudo apt-get update && sudo apt-get install spotify-client -y
|
1
src/applicationsTODO/Defold.sh
Normal file
1
src/applicationsTODO/Defold.sh
Normal file
@ -0,0 +1 @@
|
||||
echo "defold"
|
3
src/applicationsTODO/Discord.sh
Normal file
3
src/applicationsTODO/Discord.sh
Normal file
@ -0,0 +1,3 @@
|
||||
wget -O discord.deb "https://discordapp.com/api/download?platform=linux&format=deb"
|
||||
sudo dpkg -i discord.deb
|
||||
echo "y" | sudo apt install -f
|
1
src/applicationsTODO/Docker.sh
Executable file
1
src/applicationsTODO/Docker.sh
Executable file
@ -0,0 +1 @@
|
||||
apt-get update
|
0
src/applicationsTODO/Xampp.sh
Normal file
0
src/applicationsTODO/Xampp.sh
Normal file
2
src/applicationsTODO/chromium.sh
Normal file
2
src/applicationsTODO/chromium.sh
Normal file
@ -0,0 +1,2 @@
|
||||
sudo apt-get update
|
||||
sudo apt install chromium -y
|
10
src/services/connection.sh
Normal file
10
src/services/connection.sh
Normal file
@ -0,0 +1,10 @@
|
||||
check_connection() {
|
||||
wget -q --spider http://google.com
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: NO INTERNET CONNECTION. Please make sure that there is a stable internet connection."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# check_connection
|
62
src/services/help.sh
Executable file
62
src/services/help.sh
Executable file
@ -0,0 +1,62 @@
|
||||
setup_color() {
|
||||
# Only use colors if connected to a terminal
|
||||
if [ -t 1 ]; then
|
||||
RED=$(printf '\033[31m')
|
||||
GREEN=$(printf '\033[32m')
|
||||
YELLOW=$(printf '\033[33m')
|
||||
BLUE=$(printf '\033[34m')
|
||||
BOLD=$(printf '\033[1m')
|
||||
RESET=$(printf '\033[m')
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
BOLD=""
|
||||
RESET=""
|
||||
fi
|
||||
}
|
||||
|
||||
print_logo() {
|
||||
# set color
|
||||
printf %s "$YELLOW"
|
||||
cat <<'EOF'
|
||||
-------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------
|
||||
--- ---
|
||||
---██ ███ ██ ███████ ████████ █████ ██ ██ ██ ███████ ██ ██---
|
||||
---██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ---
|
||||
---██ ██ ██ ██ ███████ ██ ███████ ██ ██ ██ █████ ████ ---
|
||||
---██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ---
|
||||
---██ ██ ████ ███████ ██ ██ ██ ███████ ███████ ██ ██ ██ ---
|
||||
--- ---
|
||||
-------------------------------------------------------------------------------
|
||||
-------------------------------made by spekulaas-------------------------------
|
||||
---------------------------------Version 1.0.0---------------------------------
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
EOF
|
||||
# set color to default
|
||||
printf %s "$RESET"
|
||||
}
|
||||
|
||||
print_help() {
|
||||
# set color
|
||||
printf %s "$YELLOW"
|
||||
cat <<'EOF'
|
||||
Usage: Sudo ./install.sh [command oprions]
|
||||
|
||||
Command options:
|
||||
-h, -help Show a list of all commands
|
||||
-v, -version Show the current version of the application
|
||||
-d, -debug Display all the download information
|
||||
EOF
|
||||
# set color to default
|
||||
printf %s "$RESET"
|
||||
}
|
||||
|
||||
print_version() {
|
||||
echo "Version 1.0.0"
|
||||
}
|
16
src/services/loadbar.sh
Normal file
16
src/services/loadbar.sh
Normal file
@ -0,0 +1,16 @@
|
||||
ProgressBar() {
|
||||
# Process data
|
||||
program=(${3})
|
||||
|
||||
let _progress=(${1}*100/${2}*100)/100
|
||||
let _done=(${_progress}*4)/10
|
||||
let _left=40-$_done
|
||||
# let _program=${3}
|
||||
fill=$(printf "%${_done}s")
|
||||
empty=$(printf "%${_left}s")
|
||||
# program=$(printf "${_program}")
|
||||
|
||||
printf "\rProgress : |${fill// /▇}${empty// / }| ${_progress}%%"
|
||||
printf " Installing ${program} \r"
|
||||
|
||||
}
|
0
src/temp/.gitignore
vendored
Normal file
0
src/temp/.gitignore
vendored
Normal file
Loading…
x
Reference in New Issue
Block a user