เคสปัญหา megento มันสร้าง symbolic link พวก static file ไว้ใน pub/ แต่มันสร้างแบบ static-path ลากมาตั้งแต่ /home/ เลย เลยทำให้มันปัญหากับสิทธิ์เว็บเซิร์ฟเวอร์ในการเข้าถึงไฟล์ เก็บคำสั่งไว้คร่าวๆ ก่อนแล้วกัน
#!/bin/sh
find -type l > links
while read i; do
target=$(readlink "${i}");
if [[ $target == /home/* ]]; then
count=$(grep -o "/" <<< "$i" | wc -l)
count=$(( $count - 1 ))
prefix=$( printf "%${count}s\n" | sed "s# #../#g" );
suffix=$( echo $target | sed 's#^.*/public_html/##' );
newlink="${prefix}${suffix}"
ln -sfv $newlink $i;
fi;
done < links