Hi! Welcome to my first bash notebook. There will be two scripts featured here: An installation verification script and a github updating script. Below is the installation verification script.

Check Installation Script

# The bullet of updating a repository is addressed in the next script below

#uses basic version commands
echo Basic Python Installation Check
python --version
python2 --version
echo ""
echo ""

#uses basic version commands
echo Basic Conda Installation Check
conda --version
echo ""
echo ""

#uses basic version commands
echo Basic Jupyter Installation check
jupyter --version
echo ""
echo ""
echo Basic Checks Complete
echo ""

#sets up variables to check conda installation.
echo Check Conda Installation using Conda
conda="conda" 
checkconda=$(conda list | grep $conda)
nconda=$(echo "$checkconda" | wc -l )

#checks if conda is there or if the grep command had output
if [[ $nconda > 0 ]];
then 
    echo "$conda found!"
    echo ""
    echo ""
    echo "$checkconda"
# If there's no conda... installs conda and exits the script so the base prompt appears.
else
    echo "$conda not found. Installing so the script doesn't break!"
    echo ""
    echo ""
    cd /tmp
    wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
    chmod +x Anaconda3-2022.05-Linux-x86_64.sh
    echo "Make sure that you reply yes to the final prompt about the conda (the default is no)."
    echo "After this, the script will exit and you must reload Windows Subsystem Linux to make sure the base prompt is present."
    echo "Then, run this script again."
    ./Anaconda3-2022.05-Linux-x86_64.sh
    exit
    
fi

echo ""
echo ""

#sets up variables to check jupyter installation with conda
echo Check Jupyter Installation using Conda
jupyter="jupyter" 
checkjupyter=$(conda list | grep $jupyter)
njupyter=$(echo "$checkjupyter" | wc -l ) 

#checks if jupyter is present
if [[ $njupyter > 0 ]];  
then 
    echo "$jupyter found!"
    echo ""
    echo ""
    echo "$checkjupyter"
# jupyter not present, installs jupyter
else 
    echo "$jupyter not found, installing"
    echo ""
    echo ""
    conda install jupyter
fi

echo ""
echo ""

#sets up variables to check python with conda
echo Check Python Installation using Conda
python="python"
checkpython=$(conda list | grep $python)
npython=$(echo "$checkpython" | wc -l)

#checks if python is present
if [[ $npython > 0 ]];
then 
    echo "$python found!"
    echo ""
    echo ""
    echo "$checkpython"
# No python, installs python and related stuff
else
    echo "$python not found, installing!"
    echo ""
    echo ""
    sudo apt install python2 python3 python3-pip
    pip install bash_kernel
    python -m bash_kernel.install
    conda list | grep $python
    jupyter kernelspec list
    
fi
Basic Python Installation Check
Python 3.9.12
Python 2.7.18


Basic Conda Installation Check
conda 4.13.0


Basic Jupyter Installation check
Selected Jupyter core packages...
IPython          : 8.4.0
ipykernel        : 6.15.1
ipywidgets       : not installed
jupyter_client   : 7.3.4
jupyter_core     : 4.11.1
jupyter_server   : not installed
jupyterlab       : not installed
nbclient         : not installed
nbconvert        : not installed
nbformat         : not installed
notebook         : not installed
qtconsole        : not installed
traitlets        : 5.3.0


Basic Checks Complete

Check Conda Installation using Conda
conda found!


# packages in environment at /home/leonardw48247/anaconda3:
anaconda                  2022.05                  py39_0  
anaconda-client           1.9.0            py39h06a4308_0  
anaconda-navigator        2.1.4            py39h06a4308_0  
anaconda-project          0.10.2             pyhd3eb1b0_0  
conda                     4.13.0           py39h06a4308_0  
conda-build               3.21.8           py39h06a4308_2  
conda-content-trust       0.1.1              pyhd3eb1b0_0  
conda-env                 2.6.0                         1  
conda-pack                0.6.0              pyhd3eb1b0_0  
conda-package-handling    1.8.1            py39h7f8727e_0  
conda-repo-cli            1.0.4              pyhd3eb1b0_0  
conda-token               0.3.0              pyhd3eb1b0_0  
conda-verify              3.4.2                      py_1  


Check Jupyter Installation using Conda
jupyter found!


jupyter                   1.0.0            py39h06a4308_7  
jupyter_client            6.1.12             pyhd3eb1b0_0  
jupyter_console           6.4.0              pyhd3eb1b0_0  
jupyter_core              4.9.2            py39h06a4308_0  
jupyter_server            1.13.5             pyhd3eb1b0_0  
jupyterlab                3.3.2              pyhd3eb1b0_0  
jupyterlab_pygments       0.1.2                      py_0  
jupyterlab_server         2.10.3             pyhd3eb1b0_1  
jupyterlab_widgets        1.0.0              pyhd3eb1b0_1  


Check Python Installation using Conda
python found!


ipython                   8.2.0            py39h06a4308_0  
ipython_genutils          0.2.0              pyhd3eb1b0_1  
msgpack-python            1.0.2            py39hff7bd54_1  
python                    3.9.12               h12debd9_0  
python-dateutil           2.8.2              pyhd3eb1b0_0  
python-fastjsonschema     2.15.1             pyhd3eb1b0_0  
python-libarchive-c       2.9                pyhd3eb1b0_1  
python-lsp-black          1.0.0              pyhd3eb1b0_0  
python-lsp-jsonrpc        1.0.0              pyhd3eb1b0_0  
python-lsp-server         1.2.4              pyhd3eb1b0_0  
python-slugify            5.0.2              pyhd3eb1b0_0  
python-snappy             0.6.0            py39h2531618_3  

Github Script

echo "Using conditional statement to create a project directory and project"

# Variable section for setting project directory, the folder where the repository will be imported, and importation of repository
export project_dir=/mnt/c/project_repository  
export project=$project_dir/FastPage  
export project_repo="https://github.com/Leonard514/FastPage.git" 

cd ~    # start in home directory

# Conditional block to make a project directory... if it doesn't exist yet
if [ ! -d $project_dir ]
then 
    echo "Directory $project_dir does not exist... making directory $project_dir"
    mkdir -p $project_dir
fi
echo "Directory $project_dir exists." 

# Conditional block to git clone a project from project_repo
if [ ! -d $project ]
then
    echo "Directory $project does not exist... cloning $project_repo"
    cd $project_dir
    git clone $project_repo
    cd ~
fi
echo "Directory $project exists."

# This is meant to export a local repository to GitHub (online)
cd $project
Using conditional statement to create a project directory and project
Directory /mnt/c/project_repository does not exist... making directory /mnt/c/project_repository
Directory /mnt/c/project_repository exists.
Directory /mnt/c/project_repository/FastPage does not exist... cloning https://github.com/Leonard514/FastPage.git
Cloning into 'FastPage'...
remote: Enumerating objects: 1780, done.
remote: Counting objects: 100% (1578/1578), done.
remote: Compressing objects: 100% (606/606), done.
remote: Total 1780 (delta 828), reused 1428 (delta 761), pack-reused 202
Receiving objects: 100% (1780/1780), 14.78 MiB | 13.10 MiB/s, done.
Resolving deltas: 100% (858/858), done.
Directory /mnt/c/project_repository/FastPage exists.

Slack Check Complete!

And this? Just to let you know I have slack installed.

# test for a kernel installation
test=“python3” # keyword
check=`jupyter kernelspec list | grep $test` # run command
n=${#check} # determine length
if [[ ${n} > 0 ]];  # testt length
then # greater than zero
    echo “$check”
else # less than zero
    echo “$check”
fi

Still don't believe me? Well this should change your mind.