update scripts and add setups linux-vm and macos

This commit is contained in:
Tomas Mirchev 2025-02-24 14:25:04 +00:00
parent 1a3a374f3b
commit eada923162
6 changed files with 141 additions and 16 deletions

View File

@ -104,7 +104,7 @@ def link_environment(config, env, **kwargs):
src = package["link"]["from"]
dest = package["link"]["to"]
if dest.exists():
if dest.exists() or dest.is_symlink():
if options["force"]:
force_delete(dest)
print(f"\t> Deleted: {dest}")

View File

@ -1,9 +1,6 @@
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root using sudo."
exit 1
fi
set -e
if [ -z "$1" ]; then
echo "Usage: $0 <new-hostname>"
@ -13,8 +10,12 @@ fi
NEW_HOSTNAME=$1
OLD_HOSTNAME=$(hostname)
hostnamectl set-hostname "$NEW_HOSTNAME"
echo ""
echo "Changing hostname to '$NEW_HOSTNAME'..."
sed -i "s/$OLD_HOSTNAME/$NEW_HOSTNAME/g" /etc/hosts
sudo hostnamectl set-hostname "$NEW_HOSTNAME"
sudo sed -i "s/$OLD_HOSTNAME/$NEW_HOSTNAME/g" /etc/hosts
echo ""
echo "Hostname has been changed to: $(hostname)"

View File

View File

@ -1,22 +1,23 @@
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root using sudo."
exit 1
fi
set -e
if [ -z "$1" ]; then
echo "Usage: $0 <new-hostname>"
exit 1
fi
NEW_HOSTNAME=$1
NEW_HOSTNAME="$1"
scutil --set HostName "$NEW_HOSTNAME"
scutil --set ComputerName "$NEW_HOSTNAME"
scutil --set LocalHostName "$NEW_HOSTNAME"
echo ""
echo "Changing hostname to '$NEW_HOSTNAME'..."
echo "Hostname has been changed to:"
sudo scutil --set HostName "$NEW_HOSTNAME"
sudo scutil --set ComputerName "$NEW_HOSTNAME"
sudo scutil --set LocalHostName "$NEW_HOSTNAME"
echo ""
echo "Hostname has been updated:"
echo "HostName: $(scutil --get HostName)"
echo "ComputerName: $(scutil --get ComputerName)"
echo "LocalHostName: $(scutil --get LocalHostName)"

55
setups/linux-vm.sh Normal file
View File

@ -0,0 +1,55 @@
#!/bin/bash
set -e
if [ "$EUID" -eq 0 ]; then
echo "This script should not be run as root. Please run it as a normal user."
exit 1
fi
if [ -z "$1" ]; then
echo "Usage: $0 <new-hostname>"
exit 1
fi
NEW_HOSTNAME="$1"
if ! sudo -v; then
echo "Sudo access required. Exiting."
exit 1
fi
# /bin/bash ../scripts/linux-setup_sudoers.sh
/bin/bash ../scripts/linux-change_hostname.sh "$NEW_HOSTNAME"
echo ""
echo "Installing docker..."
/bin/bash ../scripts/linux-setup_docker.sh
echo ""
echo "Creating internal SSH keys..."
/bin/bash ../scripts/setup_ssh_keys.sh --comment "${USER}@${NEW_HOSTNAME}"
echo ""
echo "Installing packages..."
python3 ../manage.py install linux-vm
echo ""
echo "Linking config..."
python3 ../manage.py link linux-vm --force
echo ""
echo "Updating git remote origin url..."
git remote set-url origin git@gitea.tomastm.com:tomas.mirchev/dotfiles.git
echo ""
echo "Setup complete. Follow the next steps to finalize your environment:"
echo ""
echo "Update your git repository SSH key. Your public key is:"
echo " $(cat ~/.ssh/id_ed25519.pub)"
echo ""
echo "Start you development with \`dev -i <image> <container_name>\`"
echo "Example: \`dev -i node mybox\`"

68
setups/macos.sh Normal file
View File

@ -0,0 +1,68 @@
#!/bin/bash
set -e
if [ "$EUID" -eq 0 ]; then
echo "This script should not be run as root. Please run it as a normal user."
exit 1
fi
if [ -z "$1" ]; then
echo "Usage: $0 <new-hostname>"
exit 1
fi
NEW_HOSTNAME="$1"
if ! sudo -v; then
echo "Sudo access required. Exiting."
exit 1
fi
if ! command -v brew &>/dev/null; then
echo ""
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv)"
else
echo "Homebrew already installed."
fi
echo ""
echo "Installing brew packages..."
/bin/bash ../scripts/macos-brew_restore.sh
echo ""
echo "Linking configs..."
python3 ../manage.py link macos --force
echo ""
echo "Changing hostname..."
/bin/bash ../scripts/macos-change_hostname.sh "$NEW_HOSTNAME"
echo ""
echo "Creating internal SSH keys..."
/bin/bash ../scripts/setup_ssh_keys.sh --comment "${USER}@${NEW_HOSTNAME}" --filename "internal"
/bin/bash ../scripts/setup_ssh_keys.sh --comment "${USER}@${NEW_HOSTNAME}" --filename "git"
echo ""
echo "Setup complete. Follow the next steps to finalize your environment:"
echo ""
echo "Set up UTM and configure DNS settings."
echo ""
echo "Once your VMs and DNS are set up, add your SSH key to the remote server:"
echo " ssh-copy-id $USER@<server-ip>"
echo ""
echo "Add your SSH key for Git access. Your public key is:"
echo " $(cat ~/.ssh/id_ed25519_git.pub)"
echo ""
echo "Update your Git remote to use SSH instead of HTTPS:"
echo " git remote set-url origin git@gitea.tomastm.com:tomas.mirchev/dotfiles.git"
echo ""
echo "Install WindowTagger. You can find the repository here:"
echo " https://gitea.tomastm.com/tomas.mirchev/window-tagger"