Answer the question
In order to leave comments, you need to log in
Bulk editing of symlinks in Debian - HOW?
Salute to all! There is a dedicated web server on Debian (nginx + apache2), several sites were transferred to it from another server.
The user account on the old one was user1, on the new one it was user2.
The problem is this: on a new server in the /var/www/user2/data/ folder. . in different subdirectories there are many symlinks leading to images (I struggled with duplicate images)... But the path for symlinks is /var/www/ user1 /..
How to make a mass change of symlinks so that all the pictures on the site work? At the moment - they are not displayed (403- Forbidden)
The method with commenting this line in nginx.conf and creating a symlink /var/www/user1 --> /var/www/user2 - tried .. does not help
(#disable_symlinks if_not_owner from =$root_path;)
Maybe there are other ways?
Answer the question
In order to leave comments, you need to log in
here either change the path as on the old server, or make a script.
something like this:
#!/bin/bash
for i in $(find -type l -exec ls -l {} \; | awk '{ print $9 $10 $11 }')
do
#b - это сам симлинк
#e - это файл на который ссылаются.
b=`echo $i | awk -F '->' '{ print $1}'`
e=`echo $i | awk -F '->' '{ print $2}'`
echo $b
echo $e
e=`echo $e |sed 's/user1/user2/g'`
echo $e
#rm $b #удаляем симлинк и делаем новый.
#новый симлинк (выполнять с опаской, лучше проверить и перепроверить.
#снять комментарий если все будет работать как нужно
#ln -s $e $b
done
Maybe it will be easier for you to just place the files in the old path? ;)
Well, "on the forehead" the problem is solved by creating a bash-script that sorts through symlinks and for those that are broken (do not lead to a file) make a new symlink (correct), and delete the broken one.
Arranging several thousand files is not an option =) I
also tend to write a bash script ... But alas, no experience and the concept of "which side to approach" ... =-(
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question