Skip to content

Commit

Permalink
fix some scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cjlapao committed Jul 17, 2024
1 parent 50a71ca commit 53cc658
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 23 deletions.
18 changes: 12 additions & 6 deletions ai/install_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,32 @@ function install() {
echo "Installing AI toolset"

sudo apt update
sudo apt install -y --no-install-recommends pandoc netcat-openbsd curl jq gcc
sudo apt install -y --no-install-recommends pandoc netcat-openbsd curl jq gcc cmake
sudo apt install -y --no-install-recommends python3-pip python3-venv
sudo apt install -y --no-install-recommends ffmpeg libsm6 libxext6
sudo apt install -y libhdf5-dev cython3

echo "Creating virtual environment"
current_folder=$(pwd)
if [ ! -d "$HOME"/.pytorch_env ]; then
mkdir "$HOME"/.pytorch_env
if [ ! -d "$HOME"/.python_env ]; then
mkdir "$HOME"/.python_env
fi

cd "$HOME"/.pytorch_env || exit
python3 -m venv env
cd "$HOME"/.python_env || exit
python3 -m venv python_env

generate_requirements

source env/bin/activate
pip3 install --upgrade pip

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu --no-cache-dir
# pip install -r requirements.txt --no-cache-dir
pip3 install ftfy regex requests pandas seaborn facesudo
pip3 install opencv-python pycocotools tensorflow --no-cache-dir

pip3 install -r requirements.txt --no-cache-dir

echo "source /home/$USER/env/bin/activate" >> ~/.bashrc

cd "$current_folder" || exit
}
Expand Down
11 changes: 11 additions & 0 deletions ubuntu/install_desktop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh -eux

install() {
echo "Installing Desktop"
sudo apt update && sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y
sudo DEBIAN_FRONTEND=noninteractive apt install -y ubuntu-desktop lightdm
sudo snap install snap-store
}

# Starting script
install
77 changes: 60 additions & 17 deletions ubuntu/regenerate.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
#!/bin/bash

MODE="REGENERATE_ALL"
HOSTNAME=""
REBOOT="false"
while getopts "hr" opt; do
case $opt in
h)
HOSTNAME="$OPTARG"

while [[ $# -gt 0 ]]; do
case $1 in
--regenerate)
MODE="REGENERATE_ALL"
shift
;;
--regenerate-id)
MODE="REGENERATE_ID"
shift
;;
--regenerate-hostname)
MODE="REGENERATE_HOSTNAME"
shift
;;
--upgrade)
MODE="UPGRADE"
shift
;;
--get-os)
MODE="GET_OS"
;;
--hostname)
HOSTNAME=$2
shift
shift
;;
r)
-reboot)
REBOOT="true"
shift
;;
\?)
echo "Invalid option -$OPTARG" >&2
*)
echo "Invalid option $1" >&2
exit 1
;;
esac
done
Expand Down Expand Up @@ -73,14 +98,32 @@ if [ "$OS" != "linux" ]; then
exit 1
fi

renew_id
if [ -z "$HOSTNAME" ]; then
renew_hostname "$(generate_random_hostname)"
else
renew_hostname "$HOSTNAME"
fi
if [ "$MODE" == "REGENERATE_ALL" ]; then
renew_id
if [ -z "$HOSTNAME" ]; then
renew_hostname "$(generate_random_hostname)"
else
renew_hostname "$HOSTNAME"
fi

if [ "$REBOOT" == "true" ]; then
echo "Rebooting the system"
reboot
fi
if [ "$REBOOT" == "true" ]; then
echo "Rebooting the system"
reboot
fi
elif [ "$MODE" == "REGENERATE_ID" ]; then
renew_id
if [ "$REBOOT" == "true" ]; then
echo "Rebooting the system"
reboot
fi
elif [ "$MODE" == "REGENERATE_HOSTNAME" ]; then
if [ -z "$HOSTNAME" ]; then
renew_hostname "$(generate_random_hostname)"
else
renew_hostname "$HOSTNAME"
fi
elif [ "$MODE" == "UPGRADE" ]; then
upgrade_system
elif [ "$MODE" == "GET_OS" ]; then
get_os
fi

0 comments on commit 53cc658

Please sign in to comment.