I created a shell script that takes the folder name as input and creates a repo on my server while also creating a subfolder inside “www/codepixelz/” which is linked to my subfolder codepixelz.tech So if someone provides folder name as “xyz” It would create a repo called xyz.git and also a subfolder called “www/codepixelz/xyz” and can be accessed by codepixelz.tech/xyz
While this seemed to work first. I am having some issues now. The folder in www/codepixelz is created. But when I clone the bare repo to local and then add my files and push. It is pushed to git. However, the folder under “www/codepixelz” is deleted. and I can no longer access codepixelz.tech/xyz What could be the issue?
The code to create repo is as below:
if [ "$#" -eq 1 ]; then
if [ -d "$1.git" ]; then
# Control will enter here if $DIRECTORY exists.
echo "Repository $1.git already exists"
exit 0
fi
echo "*Setting up repo and web root folder for product $1"
if [ -d "/var/www/codepixelz/$1" ]; then
echo "Project already exists /product/$1"
exit 0
fi
echo "Creating git repo $1.git ..."
mkdir $1.git
mkdir /var/www/codepixelz/$1
chown dev:dev -R /var/www/codepixelz/$1
chmod 775 -R /var/www/codepixelz/$1
cd $1.git
git init --bare
git --bare update-server-info
git config core.bare false
git config receive.denycurrentbranch ignore
git config core.worktree /var/www/codepixelz/$1
echo "#!/bin/sh" | tee hooks/post-receive
echo "git checkout -f" | tee -a hooks/post-receive
echo "rm -rf /var/www/codepixelz/$1" | tee -a hooks/post-receive
chmod +x hooks/post-receive
echo "Created git repo $1.git"
echo "Clone: git clone ssh://dev@codepixelz.tech/home/dev/git/$1.git"
echo "Add into existing git repo: git remote add origin ssh://dev@codepixelz.tech/home/dev/git/$1.git"
echo "/home/dev/git/$1.git created on " >> gitLog $(date)
elif [ $project_dir -eq 2 ] ; then
if [ -d "/var/www/codepixelz/$1" ]; then
echo "Project already exists./codepixelz/$1"
exit 0
fi
echo "Creating git repo $1.git ..."
mkdir $1.git
mkdir /var/www/codepixelz/$1
chmod 775 -R /var/www/codepixelz/$1
cd $1.git
git init --bare
git --bare update-server-info
git config core.bare false
git config receive.denycurrentbranch ignore
git config core.worktree /var/www/codepixelz/$1
echo "#!/bin/sh" | tee hooks/post-receive
echo "git checkout -f" | tee -a hooks/post-receive
chmod +x hooks/post-receive
echo "Created git repo $1.git"
echo "Clone: git clone ssh://dev@codepixelz.tech/home/dev/git/$1.git"
echo "Add into existing git repo: git remote add origin ssh://dev@codepixelz.tech/home/dev/git/$1.git"
echo "/home/dev/git/$1.git created on " >> gitLog $(date)
else
echo "Enter project name to create."
fi
The error that I get is:
fatal: sha1 file ‘<stdout>’ write error: Broken pipe KiB/s error: remote unpack failed: unable to create temporary object directory error: failed to push some refs to ‘ssh://dev@codepixelz.tech/home/dev/git/xyz.git’
Any lead would be of great help.
Thanks.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @utsavrathour,
Can you let me know with how much arguments are you running the script, I can see that this depends?
Additionally, I can’t see anything worrying at the moment. What I’ll recommend is opening the script and start executing the commands one by one. That way you’ll be able to see where exactly the behaviour expected is different.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.