galeb

Једноставна статичка дистрибуција заснована на musl-у
git clone https://git.sr.ht/~strahinja/galeb
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

createlinks (861B)


      1 #!/bin/sh
      2 
      3 . ./lib/env.sh
      4 . ./lib/fun.sh
      5 
      6 symlinkdb=./lib/symlinks.tsv
      7 currentstep=$1
      8 
      9 startuid=$(id -u)
     10 
     11 recno=0
     12 (
     13 IFS=$(printf '\n')
     14 while read -r record
     15 do
     16 	recno=$((recno+1))
     17 
     18 	if [ "${recno}" -eq 1 ]; then
     19 		continue
     20 	fi
     21 
     22 	src=$(printf "${record}"	| cut -d  "$(printf '\t')" -f1)
     23 	dest=$(printf "${record}"	| cut -sd "$(printf '\t')" -f2)
     24 	step=$(printf "${record}"	| cut -sd "$(printf '\t')" -f3)
     25 
     26 	# If no step was passed, do all
     27 	if [ -n "${currentstep}" ] && \
     28 		! { echo "${step}" | grep "${currentstep}" >/dev/null 2>&1; }
     29 	then
     30 		continue
     31 	fi
     32 
     33 	if [ -z "${src}" ] || [ -z "{dest}" ]; then
     34 		msg warn "Invalid record #%d; skipping" "${recno}"
     35 		continue
     36 	fi
     37 
     38 	if [ -L "${GR}${dest}" ]; then
     39 		remove_file "${GR}${dest}" || continue
     40 	fi
     41 	msg info "ln -sf %s %s" "${src}" "${GR}${dest}"
     42 	ln -sf "${src}" "${GR}${dest}" #|| exit 1
     43 done <${symlinkdb}
     44 )
     45