diff --git a/opengist/import-github-gist-alternative.sh b/opengist/import-github-gist-alternative.sh new file mode 100755 index 0000000..cc636b9 --- /dev/null +++ b/opengist/import-github-gist-alternative.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Alternative script for importing GitHub Gists into OpenGist +# This version handles authentication differently to avoid URL parsing issues + +github_user=acedanger +opengist_user=acedanger +opengist_password="Q\$R#rGV0tMGeIc1#" +opengist_host="gist.ptrwd.com" + +curl -s https://api.github.com/users/"$github_user"/gists?per_page=100 | jq '.[] | .git_pull_url' -r | while read url; do + git clone "$url" + repo_dir=$(basename "$url" .git) + + # Add remote, push, and remove the directory + if [ -d "$repo_dir" ]; then + cd "$repo_dir" + + # Set up Git credentials for this repository + git config credential.helper store + echo "https://$opengist_user:$opengist_password@$opengist_host" > .git-credentials + git config credential.helper "store --file=.git-credentials" + + # Add remote and push + git remote add gist "https://$opengist_host/init" + git push -u gist --all + + # Clean up + rm -f .git-credentials + cd .. + rm -rf "$repo_dir" + fi +done diff --git a/opengist/import-github-gist-oauth.sh b/opengist/import-github-gist-oauth.sh new file mode 100755 index 0000000..81cf1c4 --- /dev/null +++ b/opengist/import-github-gist-oauth.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# GitHub Gist import script using GitHub token for authentication +# This script works by first logging in via GitHub OAuth and then importing + +github_user=acedanger +opengist_url="https://gist.ptrwd.com" + +echo "This script requires you to first log in to OpenGist via GitHub OAuth." +echo "Please visit: $opengist_url" +echo "Log in with your GitHub account, then return here and press Enter to continue..." +read -p "Press Enter when you've logged in via GitHub OAuth: " + +echo "Starting GitHub Gist import..." + +curl -s https://api.github.com/users/"$github_user"/gists?per_page=100 | jq '.[] | .git_pull_url' -r | while read url; do + echo "Processing gist: $url" + git clone "$url" + repo_dir=$(basename "$url" .git) + + if [ -d "$repo_dir" ]; then + cd "$repo_dir" + + # Use the web-based authentication by prompting the user + echo "For repository $repo_dir, you'll need to authenticate via browser..." + echo "When prompted, use your GitHub credentials that you used to log in to OpenGist" + + # Add remote and push + git remote add gist "$opengist_url/init" + git push -u gist --all + + cd .. + rm -rf "$repo_dir" + echo "Completed import of $repo_dir" + fi +done + +echo "Import process completed!" diff --git a/opengist/import-github-gist.sh b/opengist/import-github-gist.sh new file mode 100755 index 0000000..ecdf274 --- /dev/null +++ b/opengist/import-github-gist.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# This script imports all GitHub Gists into OpenGist. + +github_user=acedanger +opengist_user=acedanger +opengist_password="Q\$R%23rGV0tMGeIc1%23" # URL-encoded password (# becomes %23) + +opengist_url="http://$opengist_user:$opengist_password@localhost:6157/init" + +curl -s https://api.github.com/users/"$github_user"/gists?per_page=100 | jq '.[] | .git_pull_url' -r | while read url; do + git clone "$url" + repo_dir=$(basename "$url" .git) + + # Add remote, push, and remove the directory + if [ -d "$repo_dir" ]; then + cd "$repo_dir" + git remote add gist "$opengist_url" + git push -u gist --all + cd .. + rm -rf "$repo_dir" + fi +done \ No newline at end of file