88 lines
2.3 KiB
Bash
88 lines
2.3 KiB
Bash
|
#!/bin/sh
|
||
|
|
||
|
. ${LIB_DIR:-./lib}/crate.common.sh
|
||
|
. ${LIB_DIR:-./lib}/log.lib.sh
|
||
|
. ${LIB_DIR:-./lib}/vars.lib.sh
|
||
|
|
||
|
file=$1
|
||
|
action=$2
|
||
|
|
||
|
|
||
|
run_crate_config_hooks() {
|
||
|
debug "running conditional functions..."
|
||
|
for condfn in $conditionfns; do
|
||
|
debug "running \"$condfn\"..."
|
||
|
$condfn || return 1
|
||
|
done
|
||
|
files
|
||
|
}
|
||
|
|
||
|
prompt_pending_actions() {
|
||
|
echo "This crate (${crate:-${1:-unknown}}) wants to make the following changes:"
|
||
|
if [ -n "$packages_marked_for_install" ]; then
|
||
|
echo "Install these packages:"
|
||
|
for pkg in $packages_marked_for_install; do
|
||
|
echo " $pkg"
|
||
|
done
|
||
|
fi
|
||
|
if [ -n "$packages_marked_for_removal" ]; then
|
||
|
echo "Remove these packages:"
|
||
|
for pkg in $packages_marked_for_removal; do
|
||
|
echo " $pkg"
|
||
|
done
|
||
|
fi
|
||
|
if [ -n "$files_to_link" ]; then
|
||
|
echo "Link these files:"
|
||
|
for link in $files_to_link; do
|
||
|
echo " $(echo $link | sed 's/:/ \-\> /')"
|
||
|
done
|
||
|
fi
|
||
|
if [ -n "$files_to_copy" ]; then
|
||
|
echo "Copy these files:"
|
||
|
for file in $files_to_copy; do
|
||
|
echo " $(echo $file | sed 's/:/ \-\> /')"
|
||
|
done
|
||
|
fi
|
||
|
printf "Is this okay? [press enter to continue] "
|
||
|
read
|
||
|
}
|
||
|
|
||
|
|
||
|
case $action in
|
||
|
config_check)
|
||
|
if ! run_crate_config_hooks; then
|
||
|
warn "crate config failed"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
skip=0
|
||
|
trap 'skip=1' INT
|
||
|
prompt_pending_actions
|
||
|
[ $skip -eq 1 ] && exit 1
|
||
|
trap - INT
|
||
|
;;
|
||
|
run)
|
||
|
if [ "$UID" = "0" ]; then
|
||
|
.
|
||
|
for script in $scripts_to_run_as_su; do
|
||
|
debug "script $script"
|
||
|
$script
|
||
|
done
|
||
|
pm -i $packages_marked_for_install
|
||
|
pm -r $packages_marked_for_removal
|
||
|
else
|
||
|
for file in $files_to_copy; do
|
||
|
debug "link $(echo "$file" | sed 's/:/ \-\> /g')"
|
||
|
cp $(echo "$file" | sed s'/:.*//g') $(echo "$file" | sed s'/.*://g')
|
||
|
done
|
||
|
for file in $files_to_link; do
|
||
|
debug "link $(echo "$file" | sed 's/:/ \-\> /g')"
|
||
|
ln $(echo "$file" | sed s'/:.*//g') $(echo "$file" | sed s'/.*://g')
|
||
|
done
|
||
|
for script in $scripts_to_run; do
|
||
|
debug "script $script"
|
||
|
$script
|
||
|
done
|
||
|
fi
|
||
|
;;
|
||
|
esac
|