fix fork script
This commit is contained in:
parent
63b9f8a8c1
commit
16a50615f9
16
.github/workflows/delete_new_script.yaml
vendored
16
.github/workflows/delete_new_script.yaml
vendored
@ -28,9 +28,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
TITLE=$(echo '${{ github.event.issue.title }}' | tr '[:upper:]' '[:lower:]' | tr -d ' ')
|
TITLE=$(echo '${{ github.event.issue.title }}' | tr '[:upper:]' '[:lower:]' | tr -d ' ')
|
||||||
BODY='${{ github.event.issue.body }}'
|
BODY='${{ github.event.issue.body }}'
|
||||||
|
|
||||||
echo "TITLE=$TITLE" >> $GITHUB_ENV
|
echo "TITLE=$TITLE" >> $GITHUB_ENV
|
||||||
|
|
||||||
# Detect script type from issue body
|
# Detect script type from issue body
|
||||||
if echo "$BODY" | grep -qi "CT (LXC Container)"; then
|
if echo "$BODY" | grep -qi "CT (LXC Container)"; then
|
||||||
SCRIPT_TYPE="ct"
|
SCRIPT_TYPE="ct"
|
||||||
@ -48,7 +48,7 @@ jobs:
|
|||||||
SCRIPT_TYPE="ct"
|
SCRIPT_TYPE="ct"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "SCRIPT_TYPE=$SCRIPT_TYPE" >> $GITHUB_ENV
|
echo "SCRIPT_TYPE=$SCRIPT_TYPE" >> $GITHUB_ENV
|
||||||
echo "Detected: $TITLE (type: $SCRIPT_TYPE)"
|
echo "Detected: $TITLE (type: $SCRIPT_TYPE)"
|
||||||
|
|
||||||
@ -113,11 +113,11 @@ jobs:
|
|||||||
TITLE="${{ env.TITLE }}"
|
TITLE="${{ env.TITLE }}"
|
||||||
SCRIPT_TYPE="${{ env.SCRIPT_TYPE }}"
|
SCRIPT_TYPE="${{ env.SCRIPT_TYPE }}"
|
||||||
branch="delete_files_${TITLE}"
|
branch="delete_files_${TITLE}"
|
||||||
|
|
||||||
git config --global user.name "github-actions[bot]"
|
git config --global user.name "github-actions[bot]"
|
||||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git checkout -b $branch
|
git checkout -b $branch
|
||||||
|
|
||||||
# Delete files based on script type
|
# Delete files based on script type
|
||||||
case "$SCRIPT_TYPE" in
|
case "$SCRIPT_TYPE" in
|
||||||
ct)
|
ct)
|
||||||
@ -143,16 +143,16 @@ jobs:
|
|||||||
rm -f "tools/pve/${TITLE}.sh"
|
rm -f "tools/pve/${TITLE}.sh"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
git add .
|
git add .
|
||||||
if git diff --staged --quiet; then
|
if git diff --staged --quiet; then
|
||||||
echo "No files to delete. Exiting..."
|
echo "No files to delete. Exiting..."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git commit -m "Delete ${TITLE} (${SCRIPT_TYPE}) after migration to ProxmoxVE"
|
git commit -m "Delete ${TITLE} (${SCRIPT_TYPE}) after migration to ProxmoxVE"
|
||||||
git push origin $branch --force
|
git push origin $branch --force
|
||||||
|
|
||||||
gh pr create \
|
gh pr create \
|
||||||
--title "Delete ${TITLE} after Merge to Main" \
|
--title "Delete ${TITLE} after Merge to Main" \
|
||||||
--body "Automated cleanup: Delete ${TITLE} (${SCRIPT_TYPE}) files after successful migration to ProxmoxVE main repo." \
|
--body "Automated cleanup: Delete ${TITLE} (${SCRIPT_TYPE}) files after successful migration to ProxmoxVE main repo." \
|
||||||
|
|||||||
@ -36,125 +36,131 @@ AUTO_DETECT=true
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
print_header() {
|
print_header() {
|
||||||
echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
|
echo -e "\n${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
|
||||||
echo -e "${BLUE}║${NC} ProxmoxVED Fork Setup Script"
|
echo -e "${BLUE}║${NC} ProxmoxVED Fork Setup Script"
|
||||||
echo -e "${BLUE}║${NC} Configuring for your fork..."
|
echo -e "${BLUE}║${NC} Configuring for your fork..."
|
||||||
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}\n"
|
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
print_info() {
|
print_info() {
|
||||||
echo -e "${BLUE}ℹ${NC} $1"
|
echo -e "${BLUE}ℹ${NC} $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
print_success() {
|
print_success() {
|
||||||
echo -e "${GREEN}✓${NC} $1"
|
echo -e "${GREEN}✓${NC} $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
print_warning() {
|
print_warning() {
|
||||||
echo -e "${YELLOW}⚠${NC} $1"
|
echo -e "${YELLOW}⚠${NC} $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
print_error() {
|
print_error() {
|
||||||
echo -e "${RED}✗${NC} $1"
|
echo -e "${RED}✗${NC} $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Detect username from git remote
|
# Detect username from git remote
|
||||||
detect_username() {
|
detect_username() {
|
||||||
local remote_url
|
local remote_url
|
||||||
|
|
||||||
# Try to get from origin
|
# Try to get from origin
|
||||||
if ! remote_url=$(git config --get remote.origin.url 2>/dev/null); then
|
if ! remote_url=$(git config --get remote.origin.url 2>/dev/null); then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract username from SSH or HTTPS URL
|
# Extract username from SSH or HTTPS URL
|
||||||
if [[ $remote_url =~ git@github.com:([^/]+) ]]; then
|
if [[ $remote_url =~ git@github.com:([^/]+) ]]; then
|
||||||
echo "${BASH_REMATCH[1]}"
|
echo "${BASH_REMATCH[1]}"
|
||||||
elif [[ $remote_url =~ github.com/([^/]+) ]]; then
|
elif [[ $remote_url =~ github.com/([^/]+) ]]; then
|
||||||
echo "${BASH_REMATCH[1]}"
|
echo "${BASH_REMATCH[1]}"
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Detect repo name from git remote
|
# Detect repo name from git remote
|
||||||
detect_repo_name() {
|
detect_repo_name() {
|
||||||
local remote_url
|
local remote_url
|
||||||
|
|
||||||
if ! remote_url=$(git config --get remote.origin.url 2>/dev/null); then
|
if ! remote_url=$(git config --get remote.origin.url 2>/dev/null); then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract repo name (remove .git if present)
|
# Extract repo name (remove .git if present)
|
||||||
if [[ $remote_url =~ /([^/]+?)(.git)?$ ]]; then
|
if [[ $remote_url =~ /([^/]+?)(.git)?$ ]]; then
|
||||||
local repo="${BASH_REMATCH[1]}"
|
local repo="${BASH_REMATCH[1]}"
|
||||||
echo "${repo%.git}"
|
echo "${repo%.git}"
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ask user for confirmation
|
# Ask user for confirmation
|
||||||
confirm() {
|
confirm() {
|
||||||
local prompt="$1"
|
local prompt="$1"
|
||||||
local response
|
local response
|
||||||
|
|
||||||
read -p "$(echo -e ${YELLOW})$prompt (y/n)${NC} " -r response
|
read -p "$(echo -e ${YELLOW})$prompt (y/n)${NC} " -r response
|
||||||
[[ $response =~ ^[Yy]$ ]]
|
[[ $response =~ ^[Yy]$ ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update links in files
|
# Update links in files
|
||||||
update_links() {
|
update_links() {
|
||||||
local old_repo="community-scripts"
|
local old_repo="community-scripts"
|
||||||
local old_name="ProxmoxVED"
|
local old_name="ProxmoxVED"
|
||||||
local new_owner="$1"
|
local new_owner="$1"
|
||||||
local new_repo="$2"
|
local new_repo="$2"
|
||||||
local files_updated=0
|
local files_updated=0
|
||||||
|
|
||||||
print_info "Scanning for hardcoded links..."
|
print_info "Scanning for hardcoded links..."
|
||||||
|
|
||||||
# Find all markdown and shell files
|
# Update ALL shell scripts and markdown files that contain the repo URL
|
||||||
local -a files_to_update=(
|
# This includes ct/, install/, misc/, vm/, tools/, docs/
|
||||||
"docs/DEFAULTS_SYSTEM_GUIDE.md"
|
|
||||||
"docs/alpine-install.func.md"
|
|
||||||
"docs/install.func.md"
|
|
||||||
"docs/APP-install.md"
|
|
||||||
"docs/APP-ct.md"
|
|
||||||
"docs/CONTRIBUTION_GUIDE.md"
|
|
||||||
"docs/INDEX.md"
|
|
||||||
"docs/README.md"
|
|
||||||
"docs/EXIT_CODES.md"
|
|
||||||
"docs/api/README.md"
|
|
||||||
)
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
for file in "${files_to_update[@]}"; do
|
# Find all .sh files and update them
|
||||||
if [[ -f "$file" ]]; then
|
while IFS= read -r -d '' file; do
|
||||||
# Count occurrences
|
if [[ -f "$file" ]]; then
|
||||||
local count=$(grep -c "github.com/$old_repo/$old_name" "$file" 2>/dev/null || echo 0)
|
# Count occurrences of the old repo URL
|
||||||
|
local count=$(grep -c "community-scripts/ProxmoxVED" "$file" 2>/dev/null || echo 0)
|
||||||
|
|
||||||
if [[ $count -gt 0 ]]; then
|
if [[ $count -gt 0 ]]; then
|
||||||
# Backup original
|
# Replace all variations of the URL
|
||||||
cp "$file" "$file.backup"
|
sed -i "s|github.com/$old_repo/$old_name|github.com/$new_owner/$new_repo|g" "$file"
|
||||||
|
sed -i "s|raw.githubusercontent.com/$old_repo/$old_name|raw.githubusercontent.com/$new_owner/$new_repo|g" "$file"
|
||||||
|
|
||||||
# Replace links
|
((files_updated++))
|
||||||
sed -i "s|github.com/$old_repo/$old_name|github.com/$new_owner/$new_repo|g" "$file"
|
print_success "Updated $file ($count links)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < <(find . -type f \( -name "*.sh" -o -name "*.func" \) -not -path "./.git/*" -print0)
|
||||||
|
|
||||||
((files_updated++))
|
# Also update markdown docs
|
||||||
print_success "Updated $file ($count links)"
|
while IFS= read -r -d '' file; do
|
||||||
fi
|
if [[ -f "$file" ]]; then
|
||||||
fi
|
local count=$(grep -c "community-scripts/ProxmoxVED" "$file" 2>/dev/null || echo 0)
|
||||||
done
|
|
||||||
|
|
||||||
return $files_updated
|
if [[ $count -gt 0 ]]; then
|
||||||
|
sed -i "s|github.com/$old_repo/$old_name|github.com/$new_owner/$new_repo|g" "$file"
|
||||||
|
sed -i "s|raw.githubusercontent.com/$old_repo/$old_name|raw.githubusercontent.com/$new_owner/$new_repo|g" "$file"
|
||||||
|
|
||||||
|
((files_updated++))
|
||||||
|
print_success "Updated $file ($count links)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < <(find ./docs -type f -name "*.md" -print0 2>/dev/null)
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Total files updated: $files_updated"
|
||||||
|
|
||||||
|
return $files_updated
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create user git config setup info
|
# Create user git config setup info
|
||||||
create_git_setup_info() {
|
create_git_setup_info() {
|
||||||
local username="$1"
|
local username="$1"
|
||||||
|
|
||||||
cat >.git-setup-info <<'EOF'
|
cat >.git-setup-info <<'EOF'
|
||||||
# Git Configuration for ProxmoxVED Development
|
# Git Configuration for ProxmoxVED Development
|
||||||
|
|
||||||
## Recommended Git Configuration
|
## Recommended Git Configuration
|
||||||
@ -216,7 +222,7 @@ git merge upstream/main
|
|||||||
For more help, see: docs/CONTRIBUTION_GUIDE.md
|
For more help, see: docs/CONTRIBUTION_GUIDE.md
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
print_success "Created .git-setup-info file"
|
print_success "Created .git-setup-info file"
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -227,65 +233,65 @@ print_header
|
|||||||
|
|
||||||
# Parse command line arguments
|
# Parse command line arguments
|
||||||
if [[ $# -gt 0 ]]; then
|
if [[ $# -gt 0 ]]; then
|
||||||
USERNAME="$1"
|
USERNAME="$1"
|
||||||
AUTO_DETECT=false
|
AUTO_DETECT=false
|
||||||
|
|
||||||
if [[ $# -gt 1 ]]; then
|
if [[ $# -gt 1 ]]; then
|
||||||
REPO_NAME="$2"
|
REPO_NAME="$2"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Try auto-detection
|
# Try auto-detection
|
||||||
if username=$(detect_username); then
|
if username=$(detect_username); then
|
||||||
USERNAME="$username"
|
USERNAME="$username"
|
||||||
print_success "Detected GitHub username: $USERNAME"
|
print_success "Detected GitHub username: $USERNAME"
|
||||||
else
|
else
|
||||||
print_error "Could not auto-detect GitHub username from git config"
|
print_error "Could not auto-detect GitHub username from git config"
|
||||||
echo -e "${YELLOW}Please run:${NC}"
|
echo -e "${YELLOW}Please run:${NC}"
|
||||||
echo " ./setup-fork.sh YOUR_USERNAME"
|
echo " ./setup-fork.sh YOUR_USERNAME"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if repo_name=$(detect_repo_name); then
|
if repo_name=$(detect_repo_name); then
|
||||||
REPO_NAME="$repo_name"
|
REPO_NAME="$repo_name"
|
||||||
if [[ "$REPO_NAME" != "ProxmoxVED" ]]; then
|
if [[ "$REPO_NAME" != "ProxmoxVED" ]]; then
|
||||||
print_info "Detected custom repo name: $REPO_NAME"
|
print_info "Detected custom repo name: $REPO_NAME"
|
||||||
else
|
else
|
||||||
print_success "Using default repo name: ProxmoxVED"
|
print_success "Using default repo name: ProxmoxVED"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate inputs
|
# Validate inputs
|
||||||
if [[ -z "$USERNAME" ]]; then
|
if [[ -z "$USERNAME" ]]; then
|
||||||
print_error "Username cannot be empty"
|
print_error "Username cannot be empty"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$REPO_NAME" ]]; then
|
if [[ -z "$REPO_NAME" ]]; then
|
||||||
print_error "Repository name cannot be empty"
|
print_error "Repository name cannot be empty"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Show what we'll do
|
# Show what we'll do
|
||||||
echo -e "${BLUE}Configuration Summary:${NC}"
|
echo -e "${BLUE}Configuration Summary:${NC}"
|
||||||
echo " Repository URL: https://github.com/$USERNAME/$REPO_NAME"
|
echo " Repository URL: https://github.com/$USERNAME/$REPO_NAME"
|
||||||
echo " Files to update: 10 files with documentation"
|
echo " Directories to scan: ct/, install/, misc/, vm/, tools/, docs/"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Ask for confirmation
|
# Ask for confirmation
|
||||||
if ! confirm "Apply these changes?"; then
|
if ! confirm "Apply these changes?"; then
|
||||||
print_warning "Setup cancelled"
|
print_warning "Setup cancelled"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Update all links
|
# Update all links
|
||||||
if update_links "$USERNAME" "$REPO_NAME"; then
|
if update_links "$USERNAME" "$REPO_NAME"; then
|
||||||
links_changed=$?
|
links_changed=$?
|
||||||
print_success "Updated $links_changed files"
|
print_success "Updated $links_changed files"
|
||||||
else
|
else
|
||||||
print_warning "No links needed updating or some files not found"
|
print_warning "No links needed updating or some files not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create git setup info file
|
# Create git setup info file
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user