Commit 453af70f authored by Praveen Arimbrathodiyil's avatar Praveen Arimbrathodiyil
Browse files

make postrm idempotent

parent a4d8301d
......@@ -19,7 +19,9 @@ case "$1" in
# been purged.
:
# stop the service if running
service diaspora status >/dev/null && service diaspora stop
if [ service diaspora status >/dev/null ]; then
service diaspora stop
fi
rm -rf /var/lib/diaspora-common/diaspora.conf
rm -rf /var/lib/diaspora-common/database.yml
......@@ -55,17 +57,23 @@ case "$1" in
diaspora_user_home=/var/lib/diaspora
if [ -d ${diaspora_user_home} ]; then
for i in public app-assets Gemfile.lock .bundle vendor; do
test -e ${diaspora_user_home}/$i && rm -rf ${diaspora_user_home}/$i
if [ -e ${diaspora_user_home}/$i ]; then
rm -rf ${diaspora_user_home}/$i
fi
done
fi
diaspora_home=/usr/share/diaspora
if [ -d ${diaspora_home} ]; then
for i in db bin app/assets; do
test -e ${diaspora_home}/$i && rm -rf ${diaspora_home}/$i
if [ -e ${diaspora_home}/$i ]; then
rm -rf ${diaspora_home}/$i
fi
done
fi
echo "Removing user: diaspora"
id -u diaspora && userdel -r diaspora
if [ id -u diaspora ]; then
userdel -r diaspora
fi
fi
# Remove my changes to the db.
......
......@@ -22,7 +22,9 @@ case "$1" in
# been purged.
:
# stop the service if running
service diaspora status >/dev/null && service diaspora stop
if [ service diaspora status >/dev/null ]; then
service diaspora stop
fi
# These symlinked paths are managed by diaspora-common
backup_suffix=$(openssl rand -hex 4)
......@@ -35,7 +37,9 @@ case "$1" in
done
for i in ${diaspora_symlinks_list}; do
test -e ${diaspora_home}/$i && mv ${diaspora_home}/$i ${backup_dir}/$i
if [ -e ${diaspora_home}/$i ]; then
mv ${diaspora_home}/$i ${backup_dir}/$i
fi
done
rm -rf ${diaspora_home}/*
......@@ -44,7 +48,9 @@ case "$1" in
mkdir -p ${diaspora_home}/$i
done
for i in ${diaspora_symlinks_list}; do
test -e ${backup_dir}/$i && mv ${backup_dir}/$i ${diaspora_home}/$i
if [ -e ${backup_dir}/$i ]; then
mv ${backup_dir}/$i ${diaspora_home}/$i
fi
done
rm -rf ${backup_dir}
rm -rf /var/cache/diaspora-installer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment