#!/bin/sh

source "$1/Contents/Resources/common"

Uninstall_File="$app_root/Uninstall $app_name_prefix.app"
Uninstall_FileName="Uninstall $app_name_prefix"

cp -R "$1/Contents/Resources/Uninstall/Uninstall.app" "$Uninstall_File"

#defaults write "$Uninstall_File/Contents/Info" CFBundleName -string "$Uninstall_FileName"

# copy comoon to UI Resource
cp "$1/Contents/Resources/common" "$Uninstall_File/Contents/Resources/"

# copy UI icon to uninstall
cp "$dst_root/icon.icns" "$Uninstall_File/Contents/Resources/"

cd "$Uninstall_File"
chmod  -R u=rwx,go=rx .

admin_users=$(users  admin)
admin_user=""

for var_item in $admin_users; do
 
 if [ "x${admin_user}" = "x" ]; then
	admin_user="${var_item}"
 fi

done

echo "admin_user = $admin_user"

admin_groups=$(groups ${admin_user})
echo "admin_groups= ${admin_groups}"
admin_group=""
for var_item in ${admin_groups}; do
 
if [ "x${admin_group}" = "x" ]; then
	admin_group="${var_item}"
fi

done


cd "$Uninstall_File"
echo " admin_user+admin_group = ${admin_user}:${admin_group}" 
chown -R "${admin_user}:${admin_group}" .
#chmod -R  ugo=rwx .