diff options
Diffstat (limited to 'databases/phpmyadmin/files/pkg-install.in')
-rw-r--r-- | databases/phpmyadmin/files/pkg-install.in | 116 |
1 files changed, 64 insertions, 52 deletions
diff --git a/databases/phpmyadmin/files/pkg-install.in b/databases/phpmyadmin/files/pkg-install.in index bb4180b2660f..b8adfb92959b 100644 --- a/databases/phpmyadmin/files/pkg-install.in +++ b/databases/phpmyadmin/files/pkg-install.in @@ -5,66 +5,83 @@ PATH=/usr/sbin:/usr/bin:/bin ; export PATH -myadmdir=%%PREFIX%%/%%MYADMDIR%% -myadmusr=%%MYADMUSR%% -myadmgrp=%%MYADMGRP%% +pma_dir=%%WWWDIR%% +pma_usr=%%PMA_USR%% +pma_uid=%%PMA_UID%% +pma_grp=%%PMA_GRP%% +pma_gid=%%PMA_GID%% -myadmgcos="phpMyAdmin Owner" -myadmhome=/nonexistent -myadmshell=/sbin/nologin +pma_gcos="%%PMA_GCOS%%" +pma_home=%%PMA_HOME%% +pma_shell=%%PMA_SHELL%% create_group() { - local user group gcos home shell + local user uid group gid gcos home shell user=$1 - group=$2 - gcos=$3 - home=$4 - shell=$5 + uid=$2 + group=$3 + gid=$4 + gcos=$5 + home=$6 + shell=$7 - if pw groupadd -n $group ; then - echo "===> Group $group created" + + if pw group show -n $group >/dev/null 2>&1 ; then + echo "===> Using pre-existing group $group" else - cat <<-EOERRORMSG - *** Failed to create the $group group. + if pw groupadd -n $group -g $gid ; then + echo "===> Group $group created" + else + cat <<-EOERRORMSG + *** Failed to create the $group group. - Please add the $user user and $group group - manually with the commands: + Please add the $user user and $group group + manually with the commands: - pw groupadd -n $group - pw useradd -n $user -g $group -c "$gcos" \\ - -d $home -s $shell -h - + pw groupadd -n $group -g $gid + pw useradd -n $user -u $uid -g $group -c "$gcos" \\ + -d $home -s $shell -h - - and retry installing this package. - EOERRORMSG - exit 1 + and retry installing this package. + EOERRORMSG + exit 1 + fi fi + } create_user() { - local user group gcos home shell + local user uid group gid gcos home shell user=$1 - group=$2 - gcos=$3 - home=$4 - shell=$5 - - if pw useradd -n $user -g $group -c "$gcos" -d $home -s $shell -h - ; then - echo "===> Created $user user" + uid=$2 + group=$3 + gid=$4 + gcos=$5 + home=$6 + shell=$7 + + if pw user show -n $user >/dev/null 2>&1 ; then + echo "===> Using pre-existing user $user" else - cat <<-EOERRORMSG - *** Failed to create the $user user. + if pw useradd -n $user -u $uid -g $group -c "$gcos" \ + -d $home -s $shell -h - ; then + echo "===> Created $user user" + else + cat <<-EOERRORMSG + *** Failed to create the $user user. - Please add the $user user manually with the command: + Please add the $user user manually with the command: - pw useradd -n $user -g $group -c "$gcos" \\ - -d $home -s $shell -h - + pw useradd -n $user -u $uid -g $group -c "$gcos" \\ + -d $home -s $shell -h - - and retry installing this package. - EOERRORMSG - exit 1 + and retry installing this package. + EOERRORMSG + exit 1 + fi fi } @@ -72,24 +89,19 @@ create_user() { case $2 in PRE-INSTALL) - # Create the myadm user and group if they do not already exist - - if pw user show -n $myadmusr >/dev/null 2>&1 ; then - echo "===> Using pre-existing user $myadmusr" - else - if ! pw group show -n $myadmgrp >/dev/null 2>&1 ; then - create_group $myadmusr $myadmgrp "$myadmgcos" $myadmhome \ - $myadmshell - fi - create_user $myadmusr $myadmgrp "$myadmgcos" $myadmhome $myadmshell - fi + # Create the pma user and group if they do not already exist + create_group $pma_usr $pma_uid $pma_grp $pma_gid \ + "$pma_gcos" $pma_home $pma_shell + create_user $pma_usr $pma_uid $pma_grp $pma_gid \ + "$pma_gcos" $pma_home $pma_shell ;; + POST-INSTALL) # Change ownership of the phpMyAdm directory - echo "===> Adjusting file ownership in $myadmdir" - chown -R $myadmusr:$myadmgrp $myadmdir || exit 1 + echo "===> Adjusting file ownership in $pma_dir" + chown -R $pma_usr:$pma_grp $pma_dir || exit 1 ;; esac |