مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-11-30 21:32:30 +00:00
add bin file for running postal actions
هذا الالتزام موجود في:
93
bin/postal
Executable file
93
bin/postal
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )
|
||||
set -e
|
||||
|
||||
# If we're executing from /usr then we should update the root directory
|
||||
# to our default installation path and we should be allowed to sudo.
|
||||
if [ $ROOT_DIR == "/usr" ]; then
|
||||
SHOULD_SUDO="yes"
|
||||
ROOT_DIR=/opt/postal/app
|
||||
else
|
||||
SHOULD_SUDO="no"
|
||||
fi
|
||||
|
||||
# If we we can sudo and the current user isn't postal, then automatically
|
||||
# run commands as the postal user
|
||||
if [ $SHOULD_SUDO == "yes" ] && [ $USER != "postal" ]; then
|
||||
run() {
|
||||
HOME=/opt/postal
|
||||
eval "sudo -u postal $1"
|
||||
}
|
||||
else
|
||||
run() {
|
||||
eval $1
|
||||
}
|
||||
fi
|
||||
|
||||
# Enter the root directory
|
||||
cd $ROOT_DIR
|
||||
|
||||
# Run the right command
|
||||
case "$1" in
|
||||
start)
|
||||
run "procodile start"
|
||||
;;
|
||||
|
||||
stop)
|
||||
run "procodile stop -s --wait"
|
||||
;;
|
||||
|
||||
restart)
|
||||
run "procodile restart"
|
||||
;;
|
||||
|
||||
status)
|
||||
run "procodile status"
|
||||
;;
|
||||
|
||||
run)
|
||||
export LOG_TO_STDOUT=1
|
||||
run "procodile start -f --no-respawn --stop-when-none"
|
||||
;;
|
||||
|
||||
upgrade)
|
||||
run "bundle exec rake db:migrate"
|
||||
;;
|
||||
|
||||
console)
|
||||
run "bundle exec rails console"
|
||||
;;
|
||||
|
||||
initialize-config)
|
||||
run "bundle exec ruby script/generate_initial_config.rb"
|
||||
;;
|
||||
|
||||
bundle)
|
||||
if [ -n "$2" ]; then
|
||||
run "bundle install --path=$2 --without=development --jobs=4 --clean"
|
||||
else
|
||||
echo "usage: $0 bundle path/to/vendor/dir"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
version)
|
||||
run "bundle exec ruby script/version.rb"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $"Usage: $0 [command]"
|
||||
echo
|
||||
echo "Frequently used commands:"
|
||||
echo -e " * \e[35mstart|stop|restart\e[0m - start/stop/restart Postal in background"
|
||||
echo -e " * \e[35mstatus\e[0m - show the current status of Postal"
|
||||
echo -e " * \e[35mrun\e[0m - run Postal in the foreground"
|
||||
echo -e " * \e[35mversion\e[0m - show the current Postal version"
|
||||
echo
|
||||
echo "Other commands:"
|
||||
echo -e " * \e[35mconsole\e[0m - open a Postal system console (debug only)"
|
||||
echo -e " * \e[35minitialize-config\e[0m - initialize a new config directory"
|
||||
echo -e " * \e[35mupgrade\e[0m - upgrade the Postal installation"
|
||||
echo -e " * \e[35mbundle\e[0m - download & install all required Ruby dependencies"
|
||||
echo
|
||||
esac
|
||||
المرجع في مشكلة جديدة
حظر مستخدم