#!/bin/bash # TODO # echo to ~/.bashrc # PATH=$PATH:$GBINSTALLDIR/shortcuts ######################### set -e # Exit if any simple command fails if [[ $EUID -ne 0 ]]; then echo "This script must be run as root!" 1>&2 exit 1 fi echo "This is the installer script for gb-sysmenu, a set of bash, perl, ruby, etc" echo "scripts to configure and manage a Linux server running Ruby on Rails apps" echo "You can find more information about it at http://github.com/andrefs/gb-sysmenu" echo if [ -z "$GBINSTALLDIR" ]; then GBINSTALLDIR="/opt/gb-sysmenu" fi if [ -z "$GBSITESDIR" ]; then GBSITESDIR="~/public_html" fi echo "*** Creating directory '$GBINSTALLDIR'..." mkdir -p "$GBINSTALLDIR" echo "*** Cloning gb-sysmenu Git repository to '$GBINSTALLDIR'..." git clone git://github.com/andrefs/gb-sysmenu.git "$GBINSTALLDIR" 2>/dev/null cd "$GBINSTALLDIR" #git checkout develop # git submodule init 2>/dev/null # git submodule update 2>/dev/null # git submodule foreach git checkout master 2>/dev/null # git submodule foreach git pull 2>/dev/null cd - echo "*** Installing dirmenu..." curl -L http://goo.gl/rRBCN | bash echo "*** Installing gb-sysmenu..." cat << END > /usr/local/bin/gb-sysmenu #!/bin/bash export GBINSTALLDIR='$GBINSTALLDIR' GBSM_DIR_OWNER=\$(ls -ld "\$GBINSTALLDIR" | awk '{ print \$3}') GBSM_USER=\$(echo \$USER) if [ "\$GBSM_DIR_OWNER" != "\$GBSM_USER" ]; then echo "You need to own '\$GBINSTALLDIR' to run utils-menu," echo "but the current owner is '\$GBSM_DIR_OWNER'!" echo echo "Do you want to change the ownership of '\$GBINSTALLDIR'?" read -p "(sudo password will be needed) [y/N] " if [[ "\$REPLY" == "y" || "\$REPLY" == "Y" ]]; then sudo chown -R "\$GBSM_USER" "\$GBINSTALLDIR" else echo echo utils-menu aborted! exit 1 fi fi "\$GBINSTALLDIR"/gb.b_update dirmenu "\$GBINSTALLDIR" END echo "export GBSYSMENUPATH='$GBSYSMENUPATH'" > "$GBINSTALLDIR/gbsysmenurc" echo "export GBSITESDIR='$GBSITESDIR'" >> "$GBINSTALLDIR/gbsysmenurc" #echo "PATH=\"\$PATH:\$GBSYSMENUPATH/shortcuts\"" >> "$GBINSTALLDIR/gbsysmenurc" chmod +x "$GBINSTALLDIR"/gb.b_update chmod +x /usr/local/bin/gb-sysmenu echo echo "Installation finished!" echo "Run 'gb-sysmenu' to try your brand new gb-sysmenu!"