Last active
December 3, 2023 16:53
-
-
Save gitthub89/b155cb19ab739bafaff18421fc94bed0 to your computer and use it in GitHub Desktop.
Setup stuff on a fresh Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Volume name to backup | |
VOLUME_NAME="$1" | |
# Backup file name | |
BACKUP_FILE="$2" | |
if [ -z "$VOLUME_NAME" ] || [ -z "$BACKUP_FILE" ]; then | |
echo "Usage: ./backup_volume.sh [volume-name] [backup-file]" | |
exit 1 | |
fi | |
# Create a backup | |
docker run --rm -v "$VOLUME_NAME":/volume -v "$(pwd)":/backup ubuntu tar cvf "/backup/$BACKUP_FILE" -C /volume . | |
echo "Backup of $VOLUME_NAME completed as $BACKUP_FILE" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Volume name to restore to | |
VOLUME_NAME="$1" | |
# Backup file to restore from | |
BACKUP_FILE="$2" | |
if [ -z "$VOLUME_NAME" ] || [ -z "$BACKUP_FILE" ]; then | |
echo "Usage: ./restore_volume.sh [volume-name] [backup-file]" | |
exit 1 | |
fi | |
# Restore the backup | |
docker run --rm -v "$VOLUME_NAME":/volume -v "$(pwd)":/backup ubuntu bash -c "cd /volume && tar xvf /backup/$BACKUP_FILE" | |
echo "Restore of $VOLUME_NAME from $BACKUP_FILE completed" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wtf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt install gnome-install-tool | |
sudo apt-get install gnome-shell-extension-system-monitor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update package index | |
sudo apt-get update | |
# Install prerequisite packages | |
sudo apt-get install -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
software-properties-common | |
# Add Docker’s official GPG key | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
# Setup Docker stable repository | |
sudo add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) \ | |
stable" | |
# Update the apt package index again | |
sudo apt-get update | |
# Install Docker CE | |
sudo apt-get install -y docker-ce | |
# Allow current user to run Docker commands without sudo | |
sudo usermod -aG docker $USER | |
# Inform user to log out and back in | |
echo | |
echo "Docker installation is complete. Please log out and log back in OR RESTART to use Docker without 'sudo'." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Variables | |
KEY_PATH="$HOME/.ssh/id_ed25519" | |
EMAIL="[email protected]" | |
# Ask the user to confirm or input the email address | |
read -p "The current email address is set to $EMAIL. If this is correct, press enter. Otherwise, type the correct email and press enter: " input | |
if [[ ! -z "$input" ]]; then | |
EMAIL="$input" | |
fi | |
# Generate SSH key | |
if [ ! -f "$KEY_PATH" ]; then | |
ssh-keygen -t ed25519 -C "$EMAIL" -f "$KEY_PATH" -N "" | |
fi | |
# Add SSH key to ssh-agent | |
eval "$(ssh-agent -s)" | |
ssh-add "$KEY_PATH" | |
# Install keychain | |
echo 'Installing keychain...' | |
sudo apt-get install keychain -y | |
# Add keychain configuration to .bashrc | |
echo '/usr/bin/keychain --nogui $HOME/.ssh/id_ed25519' >> ~/.bashrc | |
echo 'source $HOME/.keychain/$(uname -n)-sh' >> ~/.bashrc | |
echo "You can now add the following key to your GitHub account. Here's how:" | |
echo "1. Log into your GitHub account." | |
echo "2. Click on your profile photo, then click on 'Settings'." | |
echo "3. In the user settings sidebar, click on 'SSH and GPG keys'." | |
echo "4. Click on 'New SSH key' or 'Add SSH key'." | |
echo "5. Paste your key into the 'Key' field and click 'Add SSH key'." | |
echo "Your SSH public key is:" | |
cat "$KEY_PATH.pub" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exit on error | |
set -e | |
echo "Installing prerequisites curl build-essential libssl-dev zlib1g-dev" | |
# Install prerequisites | |
sudo apt-get update | |
sudo apt-get install -y curl build-essential libssl-dev zlib1g-dev | |
# Fetch the latest Python 3 source release link | |
PYTHON_URL=$(curl -s https://www.python.org/downloads/source/ | grep -oP 'https://www.python.org/ftp/python/3\.[0-9]+(\.[0-9]+)?/Python-3\.[0-9]+(\.[0-9]+)?\.tgz' | head -n 1) | |
echo "Downloading python $PYTHON_URL" | |
# Download the Python source | |
curl -O $PYTHON_URL | |
# Extract the tarball | |
TARBALL=$(basename $PYTHON_URL) | |
tar -xzf $TARBALL | |
# Navigate into the extracted directory | |
DIR=$(basename $TARBALL .tgz) | |
cd $DIR | |
# Build Python | |
./configure --enable-optimizations | |
make -j$(nproc) | |
# Install Python | |
sudo make altinstall | |
# Fetch the just-installed Python version string | |
PYTHON_VERSION=$(./python -V 2>&1 | awk '{print $2}') | |
# Add the installed Python version to alternatives | |
sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python$PYTHON_VERSION 1 | |
# Select the installed Python version as the default | |
sudo update-alternatives --set python /usr/local/bin/python$PYTHON_VERSION | |
# Install pip for the new Python version | |
sudo /usr/local/bin/python$PYTHON_VERSION -m ensurepip | |
# Add the installed pip version to alternatives | |
sudo update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip$PYTHON_VERSION 1 | |
# Select the installed pip version as the default | |
sudo update-alternatives --set pip /usr/local/bin/pip$PYTHON_VERSION | |
echo "Successfully installed Python $PYTHON_VERSION and pip. You can use them with 'python' and 'pip'." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment