pulsar/script/post-install.sh
DeeDeeG 19b349a0dd script: Check ppm symlink, not its target
Use `test -L` rather than `test -f` for `post-install.sh`.

(Note: `[ ]` is an alternate invocation of the `test` shell builtin.)

`[ -f some_path ]`, for a symlink "dereferences" the symlink, meaning
it checks if its target (or the ultimate target, in the case of
a chain of symlinks) exists and is a real file.

By coincidence, as this runs after we extract/install ppm from the deb
or rpm, the symlink target exists and is a real file. However, if we
changed the install path for our package manager, the target might not
exist, and this step might fail.

`[ -L some_path ]` instead checks for if the path exists and is a
symlink. This is more correct -- it's more directly what we're trying
to check.

So we will use `-L` rather than `-f`.
2023-01-06 22:41:42 -05:00

20 lines
340 B
Bash

#!/bin/sh
FILESOURCE='/opt/Pulsar/resources/pulsar.sh'
FILEDEST='/usr/bin/pulsar'
if [ -f "$FILEDEST" ]
then
rm "$FILEDEST"
fi
cp "$FILESOURCE" "$FILEDEST"
SYMLINK_TARGET='/opt/Pulsar/resources/app/ppm/bin/apm'
SYMLINK_PATH='/usr/bin/ppm'
if [ -L "$SYMLINK_PATH" ]
then
rm "$SYMLINK_PATH"
fi
ln -s "$SYMLINK_TARGET" "$SYMLINK_PATH"