Add installer and uninstaller script

This commit is contained in:
2025-11-16 19:07:37 +07:00
parent fa0fce5e06
commit 4f9a72c8df
4 changed files with 107 additions and 6 deletions

View File

@@ -26,21 +26,36 @@ sudo apt install qemu-utils libguestfs-tools
## Installation
### Build from source:
### Quick Install (Recommended):
```bash
git clone <repo-url>
cd cloud-image
sudo ./install.sh
```
Installer akan otomatis:
- Install dependencies (qemu-utils, libguestfs-tools)
- Build binary
- Install ke `/usr/local/bin`
### Manual Build:
```bash
git clone <repo-url>
cd cloud-image
go build -o proxmox-cloud-image
```
### Install globally (Linux):
```bash
sudo cp proxmox-cloud-image /usr/local/bin/
sudo chmod +x /usr/local/bin/proxmox-cloud-image
```
### Uninstall:
```bash
cd cloud-image
sudo ./uninstall.sh
```
Setelah install, bisa langsung dipanggil dari mana aja:
```bash
proxmox-cloud-image -h

56
install.sh Executable file
View File

@@ -0,0 +1,56 @@
#!/bin/bash
set -e
INSTALL_DIR="/usr/local/bin"
BINARY_NAME="proxmox-cloud-image"
REPO_URL="https://github.com/yourusername/proxmox-cloud-image"
echo "=========================================="
echo "Proxmox Cloud Image Tool Installer"
echo "=========================================="
echo ""
if [ "$EUID" -ne 0 ]; then
echo "Error: This script must be run as root (use sudo)"
exit 1
fi
echo "Checking dependencies..."
if ! command -v qemu-img &> /dev/null; then
echo "Installing qemu-utils..."
apt-get update
apt-get install -y qemu-utils
fi
if ! command -v virt-customize &> /dev/null; then
echo "Installing libguestfs-tools..."
apt-get install -y libguestfs-tools
fi
if ! command -v go &> /dev/null; then
echo "Error: Go is not installed. Please install Go 1.19+ first."
echo "Visit: https://golang.org/doc/install"
exit 1
fi
echo ""
echo "Building binary..."
go build -o $BINARY_NAME
echo "Installing to $INSTALL_DIR..."
cp $BINARY_NAME $INSTALL_DIR/
chmod +x $INSTALL_DIR/$BINARY_NAME
echo ""
echo "=========================================="
echo "Installation completed successfully!"
echo "=========================================="
echo ""
echo "You can now use: $BINARY_NAME"
echo ""
echo "Examples:"
echo " $BINARY_NAME -h"
echo " $BINARY_NAME -config config.yaml"
echo " $BINARY_NAME -list-storage -proxmox-host 192.168.1.100"
echo ""

View File

@@ -197,6 +197,9 @@ func createProxmoxVM(config *Config) error {
"--serial0", "socket",
"--vga", "serial0",
},
{"qm", "set", fmt.Sprintf("%d", config.VMID),
"--ipconfig0", "ip=dhcp",
},
}
// Firewall is now handled as part of the network config (buildNetworkConfig),

27
uninstall.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
set -e
INSTALL_DIR="/usr/local/bin"
BINARY_NAME="proxmox-cloud-image"
echo "=========================================="
echo "Proxmox Cloud Image Tool Uninstaller"
echo "=========================================="
echo ""
if [ "$EUID" -ne 0 ]; then
echo "Error: This script must be run as root (use sudo)"
exit 1
fi
if [ -f "$INSTALL_DIR/$BINARY_NAME" ]; then
echo "Removing $INSTALL_DIR/$BINARY_NAME..."
rm -f "$INSTALL_DIR/$BINARY_NAME"
echo "Uninstallation completed successfully!"
else
echo "Binary not found at $INSTALL_DIR/$BINARY_NAME"
echo "Nothing to uninstall."
fi
echo ""