2013-05-23 08:03:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright 2007 Openedhand Ltd.
|
|
|
|
#
|
|
|
|
# Author: Richard Purdie <rpurdie@openedhand.com>
|
|
|
|
#
|
|
|
|
|
2013-07-19 09:39:26 +00:00
|
|
|
# The following script will run all the scriptlets found in #SYSCONFDIR#/deb-postinsts,
|
2016-07-05 12:34:43 +00:00
|
|
|
# #SYSCONFDIR#/ipk-postinsts or #SYSCONFDIR#/rpm-postinsts.
|
2013-05-23 08:03:56 +00:00
|
|
|
|
2014-03-27 12:43:57 +00:00
|
|
|
# the order of this list is important, do not change!
|
|
|
|
backend_list="rpm deb ipk"
|
|
|
|
|
|
|
|
pm_installed=false
|
|
|
|
|
|
|
|
for pm in $backend_list; do
|
|
|
|
pi_dir="#SYSCONFDIR#/$pm-postinsts"
|
|
|
|
|
2016-11-04 13:16:49 +00:00
|
|
|
if [ ! -d $pi_dir ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2014-03-27 12:43:57 +00:00
|
|
|
|
2016-11-04 13:16:49 +00:00
|
|
|
# found the package manager, it has postinsts
|
2014-03-27 12:43:57 +00:00
|
|
|
case $pm in
|
|
|
|
"deb")
|
2015-07-24 12:48:47 +00:00
|
|
|
if [ -s "#LOCALSTATEDIR#/lib/dpkg/status" ]; then
|
2014-03-27 12:43:57 +00:00
|
|
|
pm_installed=true
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
"ipk")
|
2016-11-04 13:16:49 +00:00
|
|
|
if [ -s "#LOCALSTATEDIR#/lib/opkg/status" ]; then
|
2015-06-25 18:21:16 +00:00
|
|
|
pm_installed=true
|
|
|
|
fi
|
2014-03-27 12:43:57 +00:00
|
|
|
;;
|
|
|
|
esac
|
2016-11-04 13:16:49 +00:00
|
|
|
break
|
2014-03-27 12:43:57 +00:00
|
|
|
done
|
2013-05-23 08:03:56 +00:00
|
|
|
|
2014-01-13 04:59:42 +00:00
|
|
|
remove_rcsd_link () {
|
|
|
|
if [ -n "`which update-rc.d`" ]; then
|
|
|
|
update-rc.d -f run-postinsts remove
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z "$pi_dir" ]; then
|
|
|
|
remove_rcsd_link
|
|
|
|
exit 0
|
|
|
|
fi
|
2013-05-23 08:03:56 +00:00
|
|
|
|
2016-12-05 21:48:18 +00:00
|
|
|
echo "Configuring packages on first boot...."
|
|
|
|
echo " (This may take several minutes. Please do not power off the machine.)"
|
|
|
|
|
2013-05-23 08:03:56 +00:00
|
|
|
[ -e #SYSCONFDIR#/default/postinst ] && . #SYSCONFDIR#/default/postinst
|
|
|
|
|
2014-03-06 12:15:41 +00:00
|
|
|
if [ "$POSTINST_LOGGING" = "1" ]; then
|
|
|
|
rm -f $LOGFILE
|
|
|
|
append_log=">>$LOGFILE 2>&1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
exec_postinst_scriptlets() {
|
|
|
|
for i in `ls $pi_dir`; do
|
|
|
|
i=$pi_dir/$i
|
|
|
|
echo "Running postinst $i..."
|
|
|
|
[ "$POSTINST_LOGGING" = "1" ] && eval echo "Running postinst $i..." $append_log
|
|
|
|
if [ -x $i ]; then
|
|
|
|
eval sh -c $i $append_log
|
|
|
|
rm $i
|
2013-05-23 08:03:56 +00:00
|
|
|
else
|
2014-03-06 12:15:41 +00:00
|
|
|
echo "ERROR: postinst $i failed."
|
|
|
|
[ "$POSTINST_LOGGING" = "1" ] && eval echo "ERROR: postinst $i failed." $append_log
|
|
|
|
remove_pi_dir=0
|
2013-05-23 08:03:56 +00:00
|
|
|
fi
|
2014-03-06 12:15:41 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
remove_pi_dir=1
|
|
|
|
if $pm_installed; then
|
|
|
|
case $pm in
|
|
|
|
"ipk")
|
2015-09-01 14:17:53 +00:00
|
|
|
eval opkg configure $append_log
|
2014-03-06 12:15:41 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
"deb")
|
|
|
|
eval dpkg --configure -a $append_log
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
exec_postinst_scriptlets
|
|
|
|
fi
|
2013-05-23 08:03:56 +00:00
|
|
|
|
|
|
|
# since all postinstalls executed successfully, remove the postinstalls directory
|
|
|
|
# and the rcS.d link
|
|
|
|
if [ $remove_pi_dir = 1 ]; then
|
|
|
|
rm -rf $pi_dir
|
2014-01-13 04:59:42 +00:00
|
|
|
remove_rcsd_link
|
2013-05-23 08:03:56 +00:00
|
|
|
fi
|