Commit b489542f authored by Jérome Perrin's avatar Jérome Perrin

slaprunner: improve shell

- name wrapper bash, not sh as bash behave like sh when named sh
- add -l so that bash runs as login shell and reads .bash_profile
- enable colors in profile
- output a message in profile
- remaining TODOs: a working slapos node command
parent 046b4cb7
...@@ -50,7 +50,7 @@ mode = 0644 ...@@ -50,7 +50,7 @@ mode = 0644
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-runner.cfg url = ${:_profile_base_location_}/instance-runner.cfg
output = ${buildout:directory}/template-runner.cfg.in output = ${buildout:directory}/template-runner.cfg.in
md5sum = d1913d1e0f1f3d3b1c362979888af025 md5sum = 6d6ab000fbb9a208a98e9b68d971c571
mode = 0644 mode = 0644
[template-runner-import-script] [template-runner-import-script]
...@@ -143,7 +143,7 @@ mode = 0644 ...@@ -143,7 +143,7 @@ mode = 0644
[template-bash-profile] [template-bash-profile]
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/${:filename} url = ${:_profile_base_location_}/template/${:filename}
md5sum = 39dc910743c70d5120a778779a052cad md5sum = 1c88cbca0c1e705eeb4b544ef4616097
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = bash_profile.in filename = bash_profile.in
download-only = true download-only = true
......
...@@ -530,11 +530,11 @@ template = inline: ...@@ -530,11 +530,11 @@ template = inline:
--disable-ssl \ --disable-ssl \
--disable-ssl-menu \ --disable-ssl-menu \
--unixdomain-only=$${:socket}:$(id -u):$(id -g):0600 \ --unixdomain-only=$${:socket}:$(id -u):$(id -g):0600 \
--service "/:$(id -u):$(id -g):HOME:$${shell:wrapper}" --service "/:$(id -u):$(id -g):HOME:$${shell:wrapper} -l"
[shell] [shell]
recipe = slapos.cookbook:shell recipe = slapos.cookbook:shell
wrapper = $${directory:bin}/sh wrapper = $${directory:bin}/bash
shell = ${bash:location}/bin/bash shell = ${bash:location}/bin/bash
home = $${buildout:directory} home = $${buildout:directory}
path = $${environ:PATH}:/usr/bin:/bin/:${nano:location}/bin:${vim:location}/bin:${screen:location}/bin:${git:location}/bin:${tig:location}/bin path = $${environ:PATH}:/usr/bin:/bin/:${nano:location}/bin:${vim:location}/bin:${screen:location}/bin:${git:location}/bin:${tig:location}/bin
......
...@@ -4,5 +4,38 @@ ...@@ -4,5 +4,38 @@
cd {{ workdir }} cd {{ workdir }}
export PATH={{- path }} export PATH={{- path }}
export PS1="\w $ " export PS1="$ "
export LANG="en_GB.UTF-8"
if [ -f "$HOME/.bashrc" ] ; then
source $HOME/.bashrc
fi
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# enable color support
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
fi
# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
echo "Welcome to SlapOS slaprunner shell"
echo
# TODO: how to run slapos ?
  • @jerome, I use the following in my webrunners:

    ~ $ cat `which xslapos`
    #!/bin/sh
    # run slapos command inside slaprunner with appropriate config
    
    SLAPOS_CONFIGURATION=$HOME/etc/slapos.cfg   \
    SLAPOS_CLIENT_CONFIGURATION=$SLAPOS_CONFIGURATION   \
    exec slapos "$@"

    This way slapos ... is for system slapos and xslapos ... is for slapos inside webrunner (e.g. xslapos node, xslapos proxy show, xslapos request, ...).

    Maybe it's a hack, but it is very convenient instead of constantly typing slapos --cfg ... command


    Actually maybe there should be no system slapos available inside webrunner, if we think of it as a container, and then slapos command should be setup to operate on webrunner's config by default.

  • Thanks for the feedback @kirr. I also tend to believe that inside webrunner, slapos command with no arguments should control the slapos inside webrunner and not the system wide slapos. I think this behaviour is just accidental.

  • I agree with @jerome

  • I agree with @jerome too. Anyway from inside a webrunner there should be no permissions on global slapos. So more environment variables to set by default on the runner shell.

Please register or sign in to reply
#echo "You can use the following slapos CLI commands:"
#echo "slapos node software"
#echo "slapos node instance"
#echo "slapos request"
#echo ""
# XXX for now we can use:
#echo ~/bin/supervisorctl -c ~/etc/supervisorctl.conf
#echo ~/bin/supervisorctl -c ~/srv/runner/instance/etc/supervisorctl.conf
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