mirror of
https://github.com/Hizenberg469/environment-setup.git
synced 2026-04-19 21:12:23 +03:00
complete
This commit is contained in:
194
env_setup.sh
194
env_setup.sh
@@ -32,20 +32,20 @@ RETURN_FAILURE=255
|
|||||||
PASSWORD=""
|
PASSWORD=""
|
||||||
my_vimrc='$ORIGINAL_DIR/my_vimrc'
|
my_vimrc='$ORIGINAL_DIR/my_vimrc'
|
||||||
essential_plugins=(
|
essential_plugins=(
|
||||||
"WolfgangMehner/bash-support",
|
"WolfgangMehner/bash-support"
|
||||||
"WolfgangMehner/c-support",
|
"WolfgangMehner/c-support"
|
||||||
"WolfgangMehner/perl-support",
|
"WolfgangMehner/perl-support"
|
||||||
"preservim/nerdtree",
|
"preservim/nerdtree"
|
||||||
"luochen1990/rainbow",
|
"luochen1990/rainbow"
|
||||||
"preservim/tagbar",
|
"preservim/tagbar"
|
||||||
"mbbill/undotree",
|
"mbbill/undotree"
|
||||||
"vim-airline/vim-airline",
|
"vim-airline/vim-airline"
|
||||||
"vim-airline/vim-airline-themes",
|
"vim-airline/vim-airline-themes"
|
||||||
"bfrg/vim-c-cpp-modern",
|
"bfrg/vim-c-cpp-modern"
|
||||||
"kovetskiy/vim-bash",
|
"kovetskiy/vim-bash"
|
||||||
"tomasiser/vim-code-dark",
|
"tomasiser/vim-code-dark"
|
||||||
"ArthurSonzogni/Diagon",
|
"wiwiiwiii/vim-diagon"
|
||||||
"tpope/vim-commentary",
|
"tpope/vim-commentary"
|
||||||
"tpope/vim-fugitive"
|
"tpope/vim-fugitive"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -100,34 +100,6 @@ function printStatus {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# printStatus <message> <status> {(optional}expected-status>
|
|
||||||
function logStatus {
|
|
||||||
|
|
||||||
if [ $# -lt 2 ] || [ $# -gt 3 ] ; then
|
|
||||||
echo -e "Status message and status return value is not passed.\nNeed to fail due to incorrect script."
|
|
||||||
exit $RETURN_FAILURE
|
|
||||||
fi
|
|
||||||
|
|
||||||
message=$1
|
|
||||||
status=$2
|
|
||||||
|
|
||||||
expected_status_number=$RETURN_SUCCESS
|
|
||||||
if [ $# -gt 2 ] ; then
|
|
||||||
expected_status_number=$2
|
|
||||||
fi
|
|
||||||
|
|
||||||
findFileOrDir "status.txt" "$ORIGINAL_DIR" "f"
|
|
||||||
status=$?
|
|
||||||
if [ "$status" -ne $RETURN_SUCCESS ] ; then
|
|
||||||
touch "$ORIGINAL_DIR/status.txt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $status -ne $expected_status_number ] ; then
|
|
||||||
echo -e "$message : Failure" >> $ORIGINAL_DIR/status.txt
|
|
||||||
else
|
|
||||||
echo -e "$message : Done" >> $ORIGINAL_DIR/status.txt
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# findFileOrDir <file or dir name> {(opt)dir} {(opt)type[f|d]}
|
# findFileOrDir <file or dir name> {(opt)dir} {(opt)type[f|d]}
|
||||||
# return "" if not found
|
# return "" if not found
|
||||||
@@ -162,6 +134,36 @@ properly used."
|
|||||||
return $RETURN_FAILURE
|
return $RETURN_FAILURE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# printStatus <message> <status> {(optional}expected-status>
|
||||||
|
function logStatus {
|
||||||
|
|
||||||
|
if [ $# -lt 2 ] || [ $# -gt 3 ] ; then
|
||||||
|
echo -e "Status message and status return value is not passed.\nNeed to fail due to incorrect script."
|
||||||
|
exit $RETURN_FAILURE
|
||||||
|
fi
|
||||||
|
|
||||||
|
message=$1
|
||||||
|
status=$2
|
||||||
|
|
||||||
|
expected_status_number=$RETURN_SUCCESS
|
||||||
|
if [ $# -gt 2 ] ; then
|
||||||
|
expected_status_number=$3
|
||||||
|
fi
|
||||||
|
|
||||||
|
findFileOrDir "status.txt" "$ORIGINAL_DIR" "f"
|
||||||
|
find_status=$?
|
||||||
|
if [ "$find_status" -ne $RETURN_SUCCESS ] ; then
|
||||||
|
touch "$ORIGINAL_DIR/status.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $status -ne $expected_status_number ] ; then
|
||||||
|
echo -e "$message : Failure" >> $ORIGINAL_DIR/status.txt
|
||||||
|
else
|
||||||
|
echo -e "$message : Done" >> $ORIGINAL_DIR/status.txt
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# checkPkgIsInstalled <pkg-name> {(opt)number -- whether to install the package}
|
# checkPkgIsInstalled <pkg-name> {(opt)number -- whether to install the package}
|
||||||
# number - 1 to install or 0 to not install. Defualt = 0
|
# number - 1 to install or 0 to not install. Defualt = 0
|
||||||
# return 255 -- Not installed
|
# return 255 -- Not installed
|
||||||
@@ -216,17 +218,17 @@ function checkRepoIsCloned {
|
|||||||
path=$2
|
path=$2
|
||||||
to_cloned=0
|
to_cloned=0
|
||||||
if [ $# -gt 2 ] ; then
|
if [ $# -gt 2 ] ; then
|
||||||
to_cloned=1
|
to_cloned=$3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_recursive=0
|
is_recursive=0
|
||||||
if [ $# -gt 2 ] ; then
|
if [ $# -gt 3 ] ; then
|
||||||
is_recursive=$3
|
is_recursive=$4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
repo_hosting_platform=$REPO_HOSTING_PLATFORM
|
repo_hosting_platform="$REPO_HOSTING_PLATFORM"
|
||||||
if [ $# -gt 3 ] ; then
|
if [ $# -gt 4 ] ; then
|
||||||
repo_hosting_platform=$4
|
repo_hosting_platform=$5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
findFileOrDir "$repo_name" "$path" "d" 1
|
findFileOrDir "$repo_name" "$path" "d" 1
|
||||||
@@ -234,22 +236,26 @@ function checkRepoIsCloned {
|
|||||||
if [ "$is_dir_present" -eq $RETURN_FAILURE ] ; then
|
if [ "$is_dir_present" -eq $RETURN_FAILURE ] ; then
|
||||||
if [ $to_cloned -eq 1 ] ; then
|
if [ $to_cloned -eq 1 ] ; then
|
||||||
if [ $is_recursive -eq 1 ] ; then
|
if [ $is_recursive -eq 1 ] ; then
|
||||||
git clone --recurse-submodules "$repo_hosting_platform/$repo.git" "$path"
|
cd $path
|
||||||
|
git clone --recurse-submodules "$repo_hosting_platform/$repo.git"
|
||||||
|
cd $ORIGINAL_DIR
|
||||||
else
|
else
|
||||||
git clone "$repo_hosting_platorm/$repo.git" "$path"
|
cd $path
|
||||||
|
git clone "$repo_hosting_platform/$repo.git"
|
||||||
|
cd $ORIGINAL_DIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
checkStatus 0 "Unsuccessful in cloning the repo: $repo"
|
checkStatus 0 "Unsuccessful in cloning the repo: $repo_name"
|
||||||
status=$?
|
status=$?
|
||||||
if [ $status -eq 0 ] ; then
|
if [ $status -eq 0 ] ; then
|
||||||
echo "Successfully cloned the repo: $repo"
|
echo "Successfully cloned the repo: $repo_name"
|
||||||
return $RETURN_SUCCESS #Clonned successfully
|
return $RETURN_SUCCESS #Clonned successfully
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Repo : $repo is not present."
|
echo "Repo : $repo_name is not present."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Repo: $repo is already present"
|
echo "Repo: $repo_name is already present"
|
||||||
return $RETURN_SUCCESS # Repo present
|
return $RETURN_SUCCESS # Repo present
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -310,7 +316,7 @@ function setUpPluginDir {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function setUpYCM {
|
function setUpYCM {
|
||||||
|
|
||||||
checkRepoIsCloned "ycm-core/YouCompleteMe" "$HOME/.vim/pack/default/opt" 1 1
|
checkRepoIsCloned "ycm-core/YouCompleteMe" "$HOME/.vim/pack/default/opt" 1 1
|
||||||
|
|
||||||
@@ -329,38 +335,46 @@ function setUpYCM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setUpStarscope {
|
||||||
|
|
||||||
|
checkPkgIsInstalled "ruby-dev" 1
|
||||||
|
sudo gem install starscope
|
||||||
|
checkStatus 0 "Unsuccessful in installing starscope"
|
||||||
|
status=$?
|
||||||
|
return $status
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function setUpCodeQuery {
|
function setUpCodeQuery {
|
||||||
req_packages=(
|
req_packages=(
|
||||||
build-essential,
|
"build-essential"
|
||||||
g++,
|
"g++"
|
||||||
git,
|
"git"
|
||||||
cmake,
|
"cmake"
|
||||||
ninja-build,
|
"ninja-build"
|
||||||
sqlite3,
|
"sqlite3"
|
||||||
libsqlite3-dev,
|
"libsqlite3-dev"
|
||||||
cscope,
|
"cscope"
|
||||||
pycscope,
|
"universal-ctags"
|
||||||
starscope,
|
|
||||||
universal-ctags
|
|
||||||
)
|
)
|
||||||
|
|
||||||
gui_packages=(
|
gui_packages=(
|
||||||
libglx-dev,
|
"libglx-dev"
|
||||||
libgl1-mesa-dev,
|
"libgl1-mesa-dev"
|
||||||
libvulkan-dev,
|
"libvulkan-dev"
|
||||||
libxkbcommon-dev,
|
"libxkbcommon-dev"
|
||||||
qt6-base-dev,
|
"qt6-base-dev"
|
||||||
qt6-base-dev-tools,
|
"qt6-base-dev-tools"
|
||||||
qt6-tools-dev,
|
"qt6-tools-dev"
|
||||||
qt6-tools-dev-tools,
|
"qt6-tools-dev-tools"
|
||||||
libqt6core5compact6-dev,
|
"libqt6core5compact6-dev"
|
||||||
qt6-l10n-tools,
|
"qt6-l10n-tools"
|
||||||
qt6-wayland
|
"qt6-wayland"
|
||||||
)
|
)
|
||||||
|
|
||||||
for (( i=0 ; i < ${#req_packages[@]} ; i++ ))
|
for pkg in "${req_packages[@]}"
|
||||||
do
|
do
|
||||||
checkPkgIsInstalled "$req_packages[$i]" 1
|
checkPkgIsInstalled "$pkg" 1
|
||||||
status=$?
|
status=$?
|
||||||
|
|
||||||
if [ $status -ne 0 ] ; then
|
if [ $status -ne 0 ] ; then
|
||||||
@@ -383,9 +397,9 @@ function setUpCodeQuery {
|
|||||||
cd $ORIGINAL_DIR/codequery
|
cd $ORIGINAL_DIR/codequery
|
||||||
|
|
||||||
if [ "$CODEQUERY_GUI" = "YES" ] ; then
|
if [ "$CODEQUERY_GUI" = "YES" ] ; then
|
||||||
for (( i=0 ; i < ${#gui_packages[@]} ; i++ ))
|
for pkg in "${gui_packages[$i]}"
|
||||||
do
|
do
|
||||||
checkPkgIsInstalled "$gui_packages[$i]" 1
|
checkPkgIsInstalled "$pkg" 1
|
||||||
status=$?
|
status=$?
|
||||||
|
|
||||||
if [ $status -ne 0 ] ; then
|
if [ $status -ne 0 ] ; then
|
||||||
@@ -510,6 +524,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
read -sp "Your password to executing requiring sudo access:" PASSWORD
|
read -sp "Your password to executing requiring sudo access:" PASSWORD
|
||||||
|
echo ""
|
||||||
|
|
||||||
rm $ORIGINAL_DIR/status.txt
|
rm $ORIGINAL_DIR/status.txt
|
||||||
# Setting the .vimrc first
|
# Setting the .vimrc first
|
||||||
@@ -524,14 +539,14 @@ logStatus "Setting up Plugin directory: " $status
|
|||||||
|
|
||||||
touch status.txt
|
touch status.txt
|
||||||
# Installing the plugins
|
# Installing the plugins
|
||||||
for plugins in essential_plugins
|
for plugins in "${essential_plugins[@]}"
|
||||||
do
|
do
|
||||||
checkRepoIsCloned "$plugins" "$HOME/.vim/pack/default/start" 1
|
checkRepoIsCloned "$plugins" "$HOME/.vim/pack/default/start" 1
|
||||||
status=$?
|
status=$?
|
||||||
logStatus "Installing $plugins: " $status
|
logStatus "Installing $plugins: " $status
|
||||||
done
|
done
|
||||||
|
|
||||||
for plugins in optional_plugins
|
for plugins in "${optional_plugins[@]}"
|
||||||
do
|
do
|
||||||
checkRepoIsCloned "$plugins" "$HOME/.vim/pack/default/opt" 1
|
checkRepoIsCloned "$plugins" "$HOME/.vim/pack/default/opt" 1
|
||||||
status=$?
|
status=$?
|
||||||
@@ -539,13 +554,20 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ "$INSTALL_YCM" = "YES" ] ; then
|
if [ "$INSTALL_YCM" = "YES" ] ; then
|
||||||
setUpYCM
|
getVimVersion
|
||||||
status=$?
|
version=$?
|
||||||
logStatus "Setting up YCM: " $status
|
if (( $(echo "$version > 9.1" | bc -l) )) ; then
|
||||||
|
setUpYCM
|
||||||
|
status=$?
|
||||||
|
logStatus "Setting up YCM: " $status
|
||||||
|
else
|
||||||
|
logStatus "Setting up YCM: " $RETURN_FAILURE
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$INSTALL_CODEQUERY" = "YES" ] ; then
|
if [ "$INSTALL_CODEQUERY" = "YES" ] ; then
|
||||||
setUpCodeQuery
|
setUpCodeQuery
|
||||||
|
setUpStarscope
|
||||||
status=$?
|
status=$?
|
||||||
logStatus "Setting up codequery: " $status
|
logStatus "Setting up codequery: " $status
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
ORIGINAL_DIR=$PWD
|
|
||||||
INSTALL_VIM_CODEQUERY=YES
|
|
||||||
CODEQUERY_GUI=NO
|
|
||||||
INSTALL_CODEQUERY=YES
|
|
||||||
REPO_HOSTING_PLATFORM="https://github.com"
|
|
||||||
INSTALL_YCM=YES
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
Setting up .virmc: : Failure
|
|
||||||
Setting up Plugin directory: : Done
|
|
||||||
Installing essential_plugins: : Done
|
|
||||||
Setting up optional_plusins: : Done
|
|
||||||
Reference in New Issue
Block a user