mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-19 21:03:19 -07:00
Assume FULL_PATH if installer.sh is being run from within a plexupdate directory
This commit is contained in:
parent
131a78f639
commit
b4517ea7c5
1 changed files with 51 additions and 39 deletions
|
@ -96,6 +96,51 @@ abort() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_plexupdate() {
|
||||||
|
echo
|
||||||
|
read -e -p "Directory to install into: " -i "/opt/plexupdate" FULL_PATH
|
||||||
|
|
||||||
|
while [[ "$FULL_PATH" == *"~"* ]]; do
|
||||||
|
echo "Using '~' in your path can cause problems, please type out the full path instead"
|
||||||
|
echo
|
||||||
|
read -e -p "Directory to install into: " -i "/opt/plexupdate" FULL_PATH
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -d "$FULL_PATH" ]; then
|
||||||
|
echo -n "'$FULL_PATH' doesn't exist, attempting to create... "
|
||||||
|
if ! mkdir -p "$FULL_PATH" 2>/dev/null; then
|
||||||
|
sudo mkdir -p "$FULL_PATH" || abort "failed, cannot continue"
|
||||||
|
sudo chown $(whoami) "$FULL_PATH" || abort "failed, cannot continue"
|
||||||
|
fi
|
||||||
|
echo "done"
|
||||||
|
elif [ ! -w "$FULL_PATH" ]; then
|
||||||
|
echo -n "'$FULL_PATH' exists, but you don't have permission to write to it. Changing owner... "
|
||||||
|
sudo chown $(whoami) "$FULL_PATH" || abort "failed, cannot continue"
|
||||||
|
echo "done"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "${FULL_PATH}/.git" ]; then
|
||||||
|
cd "$FULL_PATH"
|
||||||
|
if git remote -v 2>/dev/null | grep -q "plexupdate"; then
|
||||||
|
echo -n "Found existing plexupdate repository in '$FULL_PATH', updating... "
|
||||||
|
git pull &>/dev/null || abort "Unknown error while updating, please check '$FULL_PATH' and then try again."
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
abort "'$FULL_PATH' appears to contain a different git repository, cannot continue"
|
||||||
|
fi
|
||||||
|
echo "done"
|
||||||
|
cd - &> /dev/null
|
||||||
|
else
|
||||||
|
echo -n "Installing plexupdate into '$FULL_PATH'... "
|
||||||
|
git clone "$ORIGIN_REPO" "$FULL_PATH" &> /dev/null || abort "install failed, cannot continue"
|
||||||
|
echo "done"
|
||||||
|
# FIXME These 3 lines are just to allow us to test easily while we're still using this branch. Remember to take this out before merging to master.
|
||||||
|
cd "$FULL_PATH"
|
||||||
|
git checkout reworklog > /dev/null
|
||||||
|
cd - &> /dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
configure_plexupdate() {
|
configure_plexupdate() {
|
||||||
|
|
||||||
CONFIGTEMP=$(mktemp /tmp/plexupdate.tempconf.XXX)
|
CONFIGTEMP=$(mktemp /tmp/plexupdate.tempconf.XXX)
|
||||||
|
@ -278,49 +323,16 @@ if [ -f ~/.plexupdate ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
if [ -f "$(dirname $0)/../plexupdate.sh" -a -d "$(dirname $0)/../.git" ]; then
|
||||||
read -e -p "Directory to install into: " -i "/opt/plexupdate" FULL_PATH
|
FULL_PATH=$(readlink -f $(dirname $0)/../)
|
||||||
|
|
||||||
while [[ "$FULL_PATH" == *"~"* ]]; do
|
|
||||||
echo "Using '~' in your path can cause problems, please type out the full path instead"
|
|
||||||
echo
|
echo
|
||||||
read -e -p "Directory to install into: " -i "/opt/plexupdate" FULL_PATH
|
echo "Found plexupdate.sh in '$FULL_PATH', using that as your install path"
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! -d "$FULL_PATH" ]; then
|
|
||||||
echo -n "'$FULL_PATH' doesn't exist, attempting to create... "
|
|
||||||
if ! mkdir -p "$FULL_PATH" 2>/dev/null; then
|
|
||||||
sudo mkdir -p "$FULL_PATH" || abort "failed, cannot continue"
|
|
||||||
sudo chown $(whoami) "$FULL_PATH" || abort "failed, cannot continue"
|
|
||||||
fi
|
|
||||||
echo "done"
|
|
||||||
elif [ ! -w "$FULL_PATH" ]; then
|
|
||||||
echo -n "'$FULL_PATH' exists, but you don't have permission to write to it. Changing owner... "
|
|
||||||
sudo chown $(whoami) "$FULL_PATH" || abort "failed, cannot continue"
|
|
||||||
echo "done"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d "${FULL_PATH}/.git" ]; then
|
|
||||||
cd "$FULL_PATH"
|
|
||||||
if git remote -v 2>/dev/null | grep -q "plexupdate"; then
|
|
||||||
echo -n "Found existing plexupdate repository in '$FULL_PATH', updating... "
|
|
||||||
git pull &>/dev/null || abort "Unknown error while updating, please check '$FULL_PATH' and then try again."
|
|
||||||
echo
|
|
||||||
else
|
|
||||||
abort "'$FULL_PATH' appears to contain a different git repository, cannot continue"
|
|
||||||
fi
|
|
||||||
echo "done"
|
|
||||||
cd - &> /dev/null
|
|
||||||
else
|
else
|
||||||
echo -n "Installing plexupdate into '$FULL_PATH'... "
|
install_plexupdate
|
||||||
git clone "$ORIGIN_REPO" "$FULL_PATH" &> /dev/null || abort "install failed, cannot continue"
|
|
||||||
echo "done"
|
|
||||||
# FIXME These 3 lines are just to allow us to test easily while we're still using this branch. Remember to take this out before merging to master.
|
|
||||||
cd "$FULL_PATH"
|
|
||||||
git checkout reworklog > /dev/null
|
|
||||||
cd - &> /dev/null
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
configure_plexupdate
|
configure_plexupdate
|
||||||
configure_cron
|
configure_cron
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue