Fix install script for same-directory installation and improve test script robustness
This commit is contained in:
parent
70486907aa
commit
738c765d84
2 changed files with 38 additions and 11 deletions
32
install.sh
32
install.sh
|
|
@ -94,12 +94,20 @@ mkdir -p "$INSTALL_DIR"
|
|||
chown $USERNAME:docker "$INSTALL_DIR"
|
||||
|
||||
# Copy files to installation directory
|
||||
cp update-agent.sh "$INSTALL_DIR/"
|
||||
cp config-parser.sh "$INSTALL_DIR/"
|
||||
chmod +x "$INSTALL_DIR/update-agent.sh"
|
||||
chmod +x "$INSTALL_DIR/config-parser.sh"
|
||||
chown $USERNAME:docker "$INSTALL_DIR/update-agent.sh"
|
||||
chown $USERNAME:docker "$INSTALL_DIR/config-parser.sh"
|
||||
if [ "$SCRIPT_DIR" != "$INSTALL_DIR" ]; then
|
||||
cp update-agent.sh "$INSTALL_DIR/"
|
||||
cp config-parser.sh "$INSTALL_DIR/"
|
||||
chmod +x "$INSTALL_DIR/update-agent.sh"
|
||||
chmod +x "$INSTALL_DIR/config-parser.sh"
|
||||
chown $USERNAME:docker "$INSTALL_DIR/update-agent.sh"
|
||||
chown $USERNAME:docker "$INSTALL_DIR/config-parser.sh"
|
||||
else
|
||||
# Files are already in the target directory, just ensure permissions
|
||||
chmod +x "$INSTALL_DIR/update-agent.sh"
|
||||
chmod +x "$INSTALL_DIR/config-parser.sh"
|
||||
chown $USERNAME:docker "$INSTALL_DIR/update-agent.sh"
|
||||
chown $USERNAME:docker "$INSTALL_DIR/config-parser.sh"
|
||||
fi
|
||||
|
||||
# Create default .env file if it doesn't exist
|
||||
if [ ! -f "$INSTALL_DIR/.env" ]; then
|
||||
|
|
@ -123,8 +131,16 @@ EOF
|
|||
fi
|
||||
|
||||
# Copy example configuration files
|
||||
cp config.toml.example "$INSTALL_DIR/config.toml"
|
||||
chown $USERNAME:docker "$INSTALL_DIR/config.toml"
|
||||
if [ "$SCRIPT_DIR" != "$INSTALL_DIR" ]; then
|
||||
cp config.toml.example "$INSTALL_DIR/config.toml"
|
||||
chown $USERNAME:docker "$INSTALL_DIR/config.toml"
|
||||
else
|
||||
# File is already in the target directory, just ensure it exists and has proper permissions
|
||||
if [ ! -f "$INSTALL_DIR/config.toml" ]; then
|
||||
cp config.toml.example "$INSTALL_DIR/config.toml"
|
||||
fi
|
||||
chown $USERNAME:docker "$INSTALL_DIR/config.toml"
|
||||
fi
|
||||
|
||||
# Update service file with username and installation directory
|
||||
sed "s|YOUR_USERNAME|$USERNAME|g; s|/opt/composesync|$INSTALL_DIR|g" composesync.service > /etc/systemd/system/composesync.service
|
||||
|
|
|
|||
|
|
@ -6,11 +6,22 @@
|
|||
set -e
|
||||
|
||||
# Get the installation directory from the service file
|
||||
INSTALL_DIR=$(systemctl show composesync --property=ExecStart | sed 's/.*ExecStart=//' | sed 's|/update-agent.sh.*||')
|
||||
INSTALL_DIR=""
|
||||
if systemctl list-unit-files | grep -q composesync; then
|
||||
INSTALL_DIR=$(systemctl show composesync --property=ExecStart 2>/dev/null | sed 's/.*ExecStart=//' | sed 's|/update-agent.sh.*||' || echo "")
|
||||
fi
|
||||
|
||||
# If we can't get it from the service, try to determine from current directory
|
||||
if [ -z "$INSTALL_DIR" ]; then
|
||||
echo "❌ Could not determine installation directory from service"
|
||||
exit 1
|
||||
# Check if we're in a ComposeSync installation directory
|
||||
if [ -f "update-agent.sh" ] && [ -f "config-parser.sh" ]; then
|
||||
INSTALL_DIR="$(pwd)"
|
||||
echo "⚠️ Service not found, testing current directory: $INSTALL_DIR"
|
||||
else
|
||||
echo "❌ Could not determine installation directory from service or current location"
|
||||
echo " Make sure you're running this from the ComposeSync installation directory"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "🧪 Testing ComposeSync installation in: $INSTALL_DIR"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue