mla*_*the 1 linux rpm rpm-spec
我正在尝试跟踪rpm.spec文件中%pre /%post scriptlets的最佳做法.
具体来说,我的系统安装非常复杂.除此之外,它需要做很多"安全增强Linux"自定义,iptable编辑,用户创建(带密码)和"chown"等.
问题是在哪里这样做?这应该放在前/后小脚架中吗?最好的做法似乎是尽可能保持这些简单,绝对不要让它具有互动性.
我注意到Postgres安装程序(以及其他一些人)执行"手动安装后"步骤,其中root用户需要运行脚本来执行某些操作,例如设置postgres用户的密码等.您可以在下面看到rpm打印的位置这个: To initialize, run /etc/init.d/postgres-9.1-openscg start as root user.
以下是提取的scriptlet:
rpm -qp --scripts postgres-9.1.2-1.i386.openscg.rpm
Run Code Online (Sandbox Code Playgroud)
预安装scriptlet(使用/ bin/sh):
if [ "$1" = "2" ]; then
#Perform maintenance tasks before server upgrade begins.
#Determine if server is running, stops it.
/etc/init.d/postgres-9.1-openscg status &> /dev/null
if [ "$?" = "0" ];
then
/etc/init.d/postgres-9.1-openscg stop
touch /tmp/pg_9.1.stopped
fi
fi
Run Code Online (Sandbox Code Playgroud)
postinstall scriptlet(使用/ bin/sh):
if type "/usr/bin/chcon" &> /dev/null ; then
/usr/bin/chcon -t textrel_shlib_t $RPM_INSTALL_PREFIX/lib/libedit.so &> /dev/null
fi
#Create a soft link to init script
if [ ! -f /etc/init.d/postgres-9.1-openscg ]
then
ln -s $RPM_INSTALL_PREFIX/bin/postgres-9.1-openscg /etc/init.d/postgres-9.1-openscg
fi
#In case of upgrade, dump environment values file
#if [ "$1" = "2" ];
#then
#Fix for psql dumb terminal issue
LD_PRELOAD_VALUE=""
for libreadline in `find -L /lib -type f -name libreadline.\* 2> /dev/null`
do
LD_PRELOAD_VALUE="$libreadline:$LD_PRELOAD_VALUE"
done
if [ x"$LD_PRELOAD_VALUE" != x"" ];
then
LD_PRELOAD_VALUE="export LD_PRELOAD=$LD_PRELOAD_VALUE"
fi
#Dump environment values
cat <<ENVEOF > $RPM_INSTALL_PREFIX/pg91-openscg.env
#!/bin/bash
$LD_PRELOAD_VALUE
export PGHOME=$RPM_INSTALL_PREFIX
export PGDATA=$RPM_INSTALL_PREFIX/data
export PATH=$RPM_INSTALL_PREFIX/bin:\$PATH
export LD_LIBRARY_PATH=$RPM_INSTALL_PREFIX/lib:\$LD_LIBRARY_PATH
export PGUSER=postgres
export PGDATABASE=postgres
ENVEOF
#Determine port from postgresql.conf
PGPORT_VALUE=""
if [ -f $RPM_INSTALL_PREFIX/data/postgresql.conf ]; then
PGPORT_VALUE=`grep "port =" $RPM_INSTALL_PREFIX/data/postgresql.conf | sed -e "s/^.*port[[:space:]]=[[:space:]]\([0-9]\+\).*$/\1/"`
PGPORT_VALUE="export PGPORT=$PGPORT_VALUE"
cat <<ENVEOF >> $RPM_INSTALL_PREFIX/pg91-openscg.env
$PGPORT_VALUE
ENVEOF
fi
#fi
# If it is an upgrade, and we stopped a running server, start it.
if [ "$1" = "2" -a -f /tmp/pg_9.1.stopped ];
then
rm /tmp/pg_9.1.stopped
/etc/init.d/postgres-9.1-openscg start
fi
if [ "$1" = "1" ];
then
echo "PostgreSQL 9.1 is now installed in $RPM_INSTALL_PREFIX."
echo
echo "To initialize, run /etc/init.d/postgres-9.1-openscg start"
echo "as root user."
fi
if [ "$1" = "2" ];
then
echo "PostgreSQL 9.1 is upgraded in $RPM_INSTALL_PREFIX."
fi
Run Code Online (Sandbox Code Playgroud)
preuninstall scriptlet(使用/ bin/sh):
if [ "$1" = "0" ]; then
#Action is uninstallation, not called due to upgrade of a new package
#Determine if server is running, stops it.
/etc/init.d/postgres-9.1-openscg status &> /dev/null
if [ "$?" = "0" ];
then
echo "Attempting to stop server..."
/etc/init.d/postgres-9.1-openscg stop
fi
echo "Attempting to update server startup status..."
if type "/sbin/chkconfig" &> /dev/null ; then
/sbin/chkconfig --del postgres-9.1-openscg
fi
fi
Run Code Online (Sandbox Code Playgroud)
postuninstall scriptlet(使用/ bin/sh):
if [ "$1" = "0" ]; then
#Action is uninstallation, not called due to upgrade of a new package
rm /etc/init.d/postgres-9.1-openscg
echo "Uninstallation complete."
fi
Run Code Online (Sandbox Code Playgroud)
如果您的意思是与RPM安装时的用户交互相关的最佳实践,那么毫无疑问.不要这样做.做任何不需要在scriptlet中进行用户交互的事情,并告诉用户在安装后运行脚本,或者在第一次运行应用程序时获取所有信息.
| 归档时间: |
|
| 查看次数: |
13598 次 |
| 最近记录: |