L
L
LionG2021-03-01 23:04:08
linux
LionG, 2021-03-01 23:04:08

Why is a symbolic link not being created on a relative path?

Broke symbolic links in letsencrypt. I decided to write a script that will fix this ... The problem is that broken links are created, and if you use the full let to the source, then everything works fine.

domain="example.com"
num="1"

rm -f ./live/$domain/*.pem
ln -s ./archive/${domain}/cert${num}.pem ./live/${domain}/cert.pem
ln -s ./archive/${domain}/chain${num}.pem ./live/${domain}/chain.pem
ln -s ./archive/${domain}/fullchain${num}.pem ./live/${domain}/fullchain.pem
ln -s ./archive/${domain}/privkey${num}.pem ./live/${domain}/privkey.pem

#проверку проходит!
FILE="./archive/${domain}/cert${num}.pem"
if [ -f $FILE ]; then
   echo "The file '$FILE' exists."
else
   echo "The file '$FILE' in not found."
fi

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-03-01
@LionG

The relative path must be written relative to the link itself (sorry for the tautology), and not from the current directory.
For example, your link ./live/${domain}/cert.pem points to ./live/${domain}/archive/${domain}/cert${num}.pem

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question