Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
compare: ecf99e3a1f
  • 6 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Feb 16, 2012
@Tauop strip whitespace / cosmetic c114db1
@Tauop Reset all defined configuration variable before loading a configurati…
…on file
87010df
@Tauop - add VERSION file
- update build.sh :
  -> ./build.sh = use VERSION file + include ScriptHelper
  -> ./build.sh -i = Interactive mode. ask questions
fb6b43e
@Tauop Bugfix uninstall.sh
 - check unix user exists before call userdel
 - ask for deleting /etc/sshgate.conf
a547a73
@Tauop factoring 409ded2
@Tauop - bugfix installation when /etc/sshgate.conf exists but sshGate was u…
…ninstalled

- bugfix detection of ScriptHelper installation
ecf99e3
View
1  VERSION
@@ -0,0 +1 @@
+0.3-beta
View
28 build-utils/bin/core/setup.func
@@ -24,7 +24,7 @@
if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
__SETUP_FUNC__='Loaded'
- # usage: private_SED_SEPARATOR <string>
+ # usage: private_SED_SEPARATOR <string>
# desc: determine a good sed separator
private_SED_SEPARATOR () {
for s in '/' '@' ',' '|'; do
@@ -76,6 +76,7 @@ if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
echo -n "${setup_file}"
return 0;
}
+
# ----------------------------------------------------------------------------
# usage: SETUP_DISPLAY_CONF [<config-file>]
# desc: Display configuration values, with explanation, as it's interpreted by sshGate.
@@ -90,6 +91,7 @@ if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
return 1;
fi
+ private_SETUP_RESET_CONF
CONF_LOAD "${config_file}"
private_SETUP_SET_DEFAULT
@@ -156,6 +158,16 @@ if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
# ----------------------------------------------------------------------------
+ # usage: private_SETUP_RESET_CONF
+ # desc: set all configuration variable defined in /etc/sshgate.conf to empty string
+ private_SETUP_RESET_CONF () {
+ local config_file='/etc/sshgate.conf' var=
+
+ for var in $( < "${config_file}" grep '^[^#]*=' | cut -d'=' -f1 ); do
+ unset "${var}"
+ done
+ }
+
# usage: private_SETUP_SET_DEFAULT
# desc: set default value to configuration variables when they aren't set
private_SETUP_SET_DEFAULT () {
@@ -219,7 +231,9 @@ if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
cp "${config_file}" "${new_config_file}"
# load and work on a copy of sshGate configuration file ------------------
+ # FIXME: what happens if ${__CONF_FILE__} isn't set ??
old_conf_set_file="${__CONF_FILE__}"
+ private_SETUP_RESET_CONF
CONF_SET_FILE "${new_config_file}"
CONF_LOAD
private_SETUP_SET_DEFAULT
@@ -266,7 +280,10 @@ if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
private_CONF --yesno SSHGATE_MAIL_SEND "Activate mail notification system [%%%] ?"
if [ "${SSHGATE_MAIL_SEND}" = 'Y' ]; then
private_CONF SSHGATE_MAIL_TO "Who will receive mail notification (comma separated mails) [%%%] ?"
- [ -z "${SSHGATE_MAIL_TO}" ] && SSHGATE_MAIl_SEND='N'
+ if [ -z "${SSHGATE_MAIL_TO}" ]; then
+ NOTICE "As e-mail is empty, mail notification is disabled"
+ SSHGATE_MAIl_SEND='N'
+ fi
fi
private_CONF --yesno SSHGATE_USERS_MUST_ACCEPT_TOS "Do users have to accept TOS when connecting for the first time [%%%] ? "
@@ -281,7 +298,7 @@ if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
fi
else
CONF_SAVE SSHGATE_USE_REMOTE_ADMIN_CLI 'N'
- CONF_SAVE SSHGATE_SUDO_WITH_NOPASSWORD 'N'
+ CONF_SAVE SSHGATE_SUDO_WITH_NOPASSWORD 'N'
fi
# if configuration file isn't /etc/sshgate.conf, sshGate isn't installed.
@@ -296,6 +313,7 @@ if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
# reload set configuration file
CONF_SET_FILE "${old_conf_set_file}"
+ private_SETUP_RESET_CONF
CONF_LOAD
return 0;
@@ -355,7 +373,7 @@ if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
# check we are 'root' to be able to write/modify anything/anywhere
user_id=`id -u`
- [ "${user_id}" != "0" ] && KO "You must execute $0 with root privileges"
+ [ "${user_id}" != "0" ] && KO "You must execute $0 with root privileges"
# we can't get old and new configuration values, using setup !!
# first, load sshgate.conf, then sshgate.setup, so that sshgate.setup
@@ -457,6 +475,7 @@ if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
# save and load manipulated configuration file
__SSHGATE_SETUP__=
SSHGATE_DIR_DATA=
+ private_SETUP_RESET_CONF
CONF_LOAD "${config_file}"
[ -n "${SSHGATE_DIR_DATA}" ] && . "${SSHGATE_DIR_DATA}/sshgate.setup" || . "${SSHGATE_DIRECTORY}/data/sshgate.setup"
@@ -505,6 +524,7 @@ if [ "${__SETUP_FUNC__:-}" != 'Loaded' ]; then
[ -e "${home_dir}/.ssh/known_hosts" ] && chmod a=r,u+w "${home_dir}/.ssh/known_hosts"
# reload previous configuration file
+ private_SETUP_RESET_CONF
CONF_LOAD
return 0
View
18 build-utils/bin/sshgate-configure
@@ -36,6 +36,10 @@ load() {
return 2;
}
+load_or_exit() {
+ load "$1" "$2" || ( echo "[ERROR] Unable to load $2"; exit $? )
+}
+
# Load ScriptHelper libraries ------------------------------------------------
# Here is the loading order :
# - local sub-directory -> for installation/upgrade stage
@@ -54,17 +58,17 @@ if [ ! -d "${SCRIPT_HELPER_DIRECTORY:-}" ]; then
fi
# Load ScriptHelper needed libraries
-load __LIB_RANDOM__ "${SCRIPT_HELPER_DIRECTORY}/random.lib.sh" || ( echo '[ERROR] Unable to load random.lib.sh'; exit $? )
-load __LIB_MESSAGE__ "${SCRIPT_HELPER_DIRECTORY}/message.lib.sh" || ( echo '[ERROR] Unable to load message.lib.sh'; exit $? )
-load __LIB_ASK__ "${SCRIPT_HELPER_DIRECTORY}/ask.lib.sh" || ( echo '[ERROR] Unable to load ask.lib.sh'; exit $? )
-load __LIB_CONF__ "${SCRIPT_HELPER_DIRECTORY}/conf.lib.sh" || ( echo '[ERROR] Unable to load conf.lib.sh'; exit $? )
+load_or_exit __LIB_RANDOM__ "${SCRIPT_HELPER_DIRECTORY}/random.lib.sh"
+load_or_exit __LIB_MESSAGE__ "${SCRIPT_HELPER_DIRECTORY}/message.lib.sh"
+load_or_exit __LIB_ASK__ "${SCRIPT_HELPER_DIRECTORY}/ask.lib.sh"
+load_or_exit __LIB_CONF__ "${SCRIPT_HELPER_DIRECTORY}/conf.lib.sh"
# Load setup.func ! ----------------------------------------------------------
# try to load local one (installation/upgrade), then installed sshGate one
-load __SETUP_FUNC__ './bin/core/setup.func'
-load __SETUP_FUNC__ "${SSHGATE_DIR_CORE:-}/setup.func"
-load __SETUP_FUNC__ "${SSHGATE_DIRECTORY:-}/setup.func"
+load_or_exit __SETUP_FUNC__ './bin/core/setup.func'
+load_or_exit __SETUP_FUNC__ "${SSHGATE_DIR_CORE:-}/setup.func"
+load_or_exit __SETUP_FUNC__ "${SSHGATE_DIRECTORY:-}/setup.func"
[ -z "${__SETUP_FUNC__:-}" ] && ( echo 'Unable to load setup.func'; exit 2; )
View
61 build-utils/install.sh
@@ -84,47 +84,56 @@ MESSAGE " by Patrick Guiran"
BR
if [ -r /etc/sshgate.conf ]; then
- action='update'
- MESSAGE "It seems that sshGate is already installed on your system."
+ MESSAGE "sshGate configuration file found."
ASK --yesno reply \
"Do you want to re-use the installed configuration [Y] ?" \
'Y'
[ "${reply}" = 'Y' ] && configure='no'
- # get installed version and this package version to know wether
- # we have to make migration (update sshGate internal data)
- CONF_GET --conf-file ./data/sshgate.conf SSHGATE_VERSION this_version
- CONF_GET --conf-file /etc/sshgate.conf SSHGATE_VERSION installed_version
-
- # old version of sshGate hasn't a SSHGATE_VERSION conf variable
- [ -z "${installed_version}" ] && installed_version='0'
+ # check if sshGate is still installed
+ CONF_GET --conf-file /etc/sshgate.conf SSHGATE_DIRECTORY installed_version_dir
+ if [ -d "${installed_version_dir}" ]; then
+ BR
+ MESSAGE "It seems that sshGate is already installed on your system."
+ action='update'
+ # get installed version and this package version to know wether
+ # we have to make migration (update sshGate internal data)
+ CONF_GET --conf-file ./data/sshgate.conf SSHGATE_VERSION this_version
+ CONF_GET --conf-file /etc/sshgate.conf SSHGATE_VERSION installed_version
+
+ # old version of sshGate hasn't a SSHGATE_VERSION conf variable
+ [ -z "${installed_version}" ] && installed_version='0'
+ fi
fi
-if [ "${configure}" = 'yes' ]; then
- # ScriptHelper dependency
- if [ -r /etc/ScriptHelper.conf ]; then
- CONF_GET --conf-file /etc/ScriptHelper.conf SCRIPT_HELPER_DIRECTORY
- elif [ "${action}" = 'install' ]; then
- if [ ! -d ./lib/ ]; then
- ERROR "sshGate depends on ScriptHelper which doesn't seem to be installed"
- exit 1;
- fi
- BR
- NOTICE "ScriptHelper will be installed as part of sshGate, not system-wide"
- MESSAGE "If you want to install ScriptHelper system-wide, please visit http://github.com/Tauop/ScriptHelper"
- BR
- install_script_helper='Y'
+
+# ScriptHelper dependency
+if [ -r /etc/ScriptHelper.conf ]; then
+ CONF_GET --conf-file /etc/ScriptHelper.conf SCRIPT_HELPER_DIRECTORY
+elif [ "${action}" = 'install' ]; then
+ if [ ! -d ./lib/ ]; then
+ ERROR "sshGate depends on ScriptHelper which doesn't seem to be installed"
+ exit 1;
fi
- CONF_SAVE SCRIPT_HELPER_DIRECTORY
+ BR
+ NOTICE "ScriptHelper will be installed as part of sshGate, not system-wide"
+ MESSAGE "If you want to install ScriptHelper system-wide, please visit http://github.com/Tauop/ScriptHelper"
+ BR
+ install_script_helper='Y'
+fi
+CONF_SAVE SCRIPT_HELPER_DIRECTORY
+
+# ----------------------------------------------------------------------------
+if [ "${configure}" = 'yes' ]; then
# configure sshGate installation
# sh ./bin/sshgate-configure --silent configure ./data/sshgate.conf
SETUP_CONFIGURE ./data/sshgate.conf
-
+ BR
fi # end of : if [ "${configure}" = 'yes' ]; then
# ----------------------------------------------------------------------------
-BR ; BR
+BR
if [ "${action}" = 'update' ]; then
chmod +x ./do_migration.sh
View
12 build-utils/uninstall.sh
@@ -70,6 +70,7 @@ if [ "${reply}" = 'N' ]; then
BR
MESSAGE "Canceled !"
BR
+ exit 0
fi
CONF_SET_FILE /etc/sshgate.conf
@@ -82,8 +83,10 @@ done
# delete sshGate Unix user
home_dir=$( cat /etc/passwd | grep "^${SSHGATE_GATE_ACCOUNT}:" | cut -d':' -f6 )
-userdel "${SSHGATE_GATE_ACCOUNT}"
-[ -d "${home_dir}" ] && rm -rf "${home_dir}"
+if [ -n "${home_dir}" ]; then
+ userdel "${SSHGATE_GATE_ACCOUNT}"
+ [ -d "${home_dir}" ] && rm -rf "${home_dir}"
+fi
# remove sshGate sudoer entry
file="/tmp/file.$(RANDOM)"
@@ -92,7 +95,10 @@ mv "${file}" /etc/sudoers
chmod 0440 /etc/sudoers
# delete global configuration
-rm -f /etc/sshgate.conf
+ASK --yesno reply "Delete /etc/sshgate.conf global configuration file [N] ?" 'N'
+if [ "${reply}" = 'Y' ]; then
+ rm -f /etc/sshgate.conf
+fi
BR
MESSAGE "sshGate is uninstalled"
View
28 build.sh
@@ -18,6 +18,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+INTERACTIVE_MODE='N'
+if [ "$1" = '-i' ]; then
+ INTERACTIVE_MODE='Y'
+fi
+
# load dependencies
load() {
local var= value= file=
@@ -54,22 +59,26 @@ load __LIB_ASK__ "${SCRIPT_HELPER_DIRECTORY}/ask.lib.sh"
# ----------------------------------------------------------------------------
version=
-ASK version "sshgate version ?"
-# build are used for testing :-) (can be empty)
-build=
-ASK --allow-empty build "sshGate build number ?"
+if [ "${INTERACTIVE_MODE}" = 'Y' ]; then
+ ASK version "sshgate version ?"
-include_script_helper='N'
-if [ "${action}" = 'all' -o "${action}" = 'server' ]; then
+ # build are used for testing :-) (can be empty)
+ build=
+ ASK --allow-empty build "sshGate build number ?"
+ [ -n "${build}" ] && version="${version}-${build}"
+
+ include_script_helper='N'
ASK --yesno include_script_helper 'Include ScriptHelper in package ?'
+else
+ version=$( cat VERSION )
+ include_script_helper='Y'
fi
# ----------------------------------------------------------------------------
DOTHIS 'Build sshgate-server package'
softname=sshGate-server-${version}
- [ -n "${build}" ] && softname="${softname}-${build}"
dir="/tmp/${softname}"
[ -d "${dir}/" ] && rm -rf "${dir}/"
@@ -79,8 +88,9 @@ DOTHIS 'Build sshgate-server package'
export COPYFILE_DISABLE=true
cp -r ./ "${dir}/"
- if [ "${include_script_helper}" = 'Y' ]; then
- cp -r ./lib ${dir}/
+ if [ "${include_script_helper}" = 'N' ]; then
+# cp -r ./lib ${dir}/
+ rm -rf "${dir}/lib/"
fi
# specific action for package built with build.sh script

No commit comments for this range

Something went wrong with that request. Please try again.