|
|
|
@@ -1,11 +1,12 @@
|
|
|
|
#!/usr/bin/bash
|
|
|
|
#!/usr/bin/bash
|
|
|
|
repos="/tmp/repos-$(cat /dev/urandom | base64 | tr -d '=+/' | head -c 8)"
|
|
|
|
N=/dev/null
|
|
|
|
|
|
|
|
repos="/tmp/repos-$(cat /dev/urandom 2>$N | base64 2>$N | tr -d '=+/' 2>$N | head -c 8)"
|
|
|
|
if [ -d "$repos" ]; then
|
|
|
|
if [ -d "$repos" ]; then
|
|
|
|
echo "Error: Temporary directory '$repos' already exists." >&2
|
|
|
|
echo "Error: Temporary directory '$repos' already exists." >&2
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
mkdir -p "$repos"
|
|
|
|
mkdir -p "$repos"
|
|
|
|
tmp_portfolio="/tmp/portfolio-$(cat /dev/urandom | base64 | tr -d '=+/' | head -c 8)"
|
|
|
|
tmp_portfolio="/tmp/portfolio-$(cat /dev/urandom 2>$N | base64 2>$N | tr -d '=+/' 2>$N | head -c 8)"
|
|
|
|
if [ -d "$tmp_portfolio" ]; then
|
|
|
|
if [ -d "$tmp_portfolio" ]; then
|
|
|
|
echo "Error: Temporary directory '$tmp_portfolio' already exists." >&2
|
|
|
|
echo "Error: Temporary directory '$tmp_portfolio' already exists." >&2
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
@@ -16,10 +17,13 @@ function safely_remove_tmp_repos() {
|
|
|
|
echo "Warning: No git repositories found in '$repos'. Not deleting to prevent data loss."
|
|
|
|
echo "Warning: No git repositories found in '$repos'. Not deleting to prevent data loss."
|
|
|
|
rmdir "$repos" 2>/dev/null
|
|
|
|
rmdir "$repos" 2>/dev/null
|
|
|
|
return
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
rm -rf "$repos"
|
|
|
|
rm -rf "$repos"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$tmp_portfolio" ] && [ -d "$tmp_portfolio" ]; then
|
|
|
|
rm -r "$tmp_portfolio"
|
|
|
|
rm -r "$tmp_portfolio"
|
|
|
|
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function cleanup() {
|
|
|
|
function cleanup() {
|
|
|
|
safely_remove_tmp_repos
|
|
|
|
safely_remove_tmp_repos
|
|
|
|
@@ -161,14 +165,15 @@ EOF
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
)"
|
|
|
|
)"
|
|
|
|
done < <(my_curl)
|
|
|
|
done < <(my_curl)
|
|
|
|
portfolio_index="$(
|
|
|
|
if [ "$portfolio_index" ]; then
|
|
|
|
cat <<EOF
|
|
|
|
portfolio_index="$(
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<head>
|
|
|
|
<title>Projects</title>
|
|
|
|
<title>Projects</title>
|
|
|
|
<body>
|
|
|
|
<body>
|
|
|
|
<h1>Projects</h1>
|
|
|
|
<h2>Projects</h2>
|
|
|
|
<div id="git-portfolio">
|
|
|
|
<div id="git-portfolio">
|
|
|
|
<style>
|
|
|
|
<style>
|
|
|
|
#git-portfolio {
|
|
|
|
#git-portfolio {
|
|
|
|
@@ -181,19 +186,23 @@ cat <<EOF
|
|
|
|
border-radius: 20px;
|
|
|
|
border-radius: 20px;
|
|
|
|
background: linear-gradient(30deg, rgba(100, 43, 200, 0.4), rgba(198, 66, 110, 0.4));
|
|
|
|
background: linear-gradient(30deg, rgba(100, 43, 200, 0.4), rgba(198, 66, 110, 0.4));
|
|
|
|
position: relative;
|
|
|
|
position: relative;
|
|
|
|
width: calc(100% - 25px);
|
|
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
box-sizing: border-box;
|
|
|
|
max-width: 420px;
|
|
|
|
max-width: 100%;
|
|
|
|
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#git-portfolio a {
|
|
|
|
#git-portfolio a {
|
|
|
|
color: black;
|
|
|
|
color: black;
|
|
|
|
text-decoration: none;
|
|
|
|
text-decoration: none;
|
|
|
|
display: inline-flex;
|
|
|
|
display: inline-flex;
|
|
|
|
flex-direction: column;
|
|
|
|
flex-direction: column;
|
|
|
|
flex-grow: 1;
|
|
|
|
max-width: calc(100%);
|
|
|
|
min-width: 400px;
|
|
|
|
|
|
|
|
max-width: 450px;
|
|
|
|
|
|
|
|
box-sizing: content-box;
|
|
|
|
box-sizing: content-box;
|
|
|
|
|
|
|
|
width: 25%;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 800px) {
|
|
|
|
|
|
|
|
#git-portfolio a {
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#git-portfolio section ul.languages {
|
|
|
|
#git-portfolio section ul.languages {
|
|
|
|
float: right;
|
|
|
|
float: right;
|
|
|
|
@@ -215,8 +224,11 @@ li.language {
|
|
|
|
$portfolio_index
|
|
|
|
$portfolio_index
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
)"
|
|
|
|
)"
|
|
|
|
echo "$portfolio_index" > "$tmp_portfolio/index.html"
|
|
|
|
echo "$portfolio_index" > "$tmp_portfolio/index.html"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo "Warning: No public repositories found for user '$GIT_USER'. Portfolio will be empty." >&2
|
|
|
|
|
|
|
|
fi
|
|
|
|
if [ -d "$directory" ]; then
|
|
|
|
if [ -d "$directory" ]; then
|
|
|
|
if [ "$(du -sb "$directory" | cut -f1)" -gt $((1024 * 1024 * 400)) ]; then
|
|
|
|
if [ "$(du -sb "$directory" | cut -f1)" -gt $((1024 * 1024 * 400)) ]; then
|
|
|
|
echo "Error: Directory '$directory' contains more than 400MB of data. Exiting to prevent data loss."
|
|
|
|
echo "Error: Directory '$directory' contains more than 400MB of data. Exiting to prevent data loss."
|
|
|
|
@@ -226,3 +238,4 @@ else
|
|
|
|
mkdir -p "$directory"
|
|
|
|
mkdir -p "$directory"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
rsync -a "$tmp_portfolio/" "$directory/"
|
|
|
|
rsync -a "$tmp_portfolio/" "$directory/"
|
|
|
|
|
|
|
|
echo "Done! Portfolio generated in '$directory'." >&2
|
|
|
|
|