Skip to content
Browse files

Added TODOs to each file

  • Loading branch information...
1 parent 7ad64d1 commit 2971a5ab3487295c1622a0e2e9574eccdf9ef5db @bergerx committed Jan 13, 2012
Showing with 38 additions and 5 deletions.
  1. +1 −2 TODO
  2. +1 −1 config
  3. +3 −0 guest-chroot
  4. +1 −0 guest-config
  5. +3 −0 guest-copy
  6. +6 −0 guest-create
  7. +1 −0 guest-destroy
  8. +2 −0 guest-list
  9. +1 −0 guest-login
  10. +2 −0 guest-restart
  11. +1 −0 guest-start
  12. +1 −0 guest-stop
  13. +2 −1 host-check
  14. +3 −0 template-chroot
  15. +3 −0 template-copy
  16. +5 −1 template-create
  17. +1 −0 template-destroy
  18. +1 −0 template-list
View
3 TODO
@@ -1,5 +1,4 @@
-* IP parameter must not be mandatory for guest-create, sl should automatically assign one if not given
+* Solve these "grep TODO *"
* Add help messages for each script, just hitting enter without parameters must show what to do
-* Add parameter checks for every script
* Add log for each action taken
* Add error hadlers, trapping ERR and INT is needed, each script must clean its waste if there is some
View
2 config
@@ -7,4 +7,4 @@ BIN_DIR=/home/bekir/repos/simplelxc
TEMPLATES_DIR=/var/lib/simplelxc/templates
DEBOOTSTRAPS_DIR=/var/lib/simplelxc/debootstraps
LXCS_DIR=/var/lib/lxc
-DEFAULT_TEMPLATE=squeeze
+DEFAULT_TEMPLATE=wheezy
View
3 guest-chroot
@@ -1,4 +1,7 @@
#!/bin/bash
name=$1
+# TODO: check if $name is an lxc name
. /etc/simplelxc
+# TODO: show a warning about "debian runs any installed servise immediately,
+# don't install services in chroot"
chroot $LXCS_DIR/$name/rootfs
View
1 guest-config
@@ -1,5 +1,6 @@
#!/bin/bash
name=$1
+# TODO: check if $name is an lxc name
. /etc/simplelxc
vi $LXCS_DIR/$name/config
View
3 guest-copy
@@ -2,6 +2,9 @@
from=$1
to=$2
ip=$4
+# TODO: check if $from is an existing lxc name
+# TODO: check if an lxc with name $to not exists
+# TODO: check if given ip address in use either by an other host or a stopped guest
. /etc/simplelxc
oldip=$(cat $LXCS_DIR/$from/rootfs/etc/hosts | awk "/$from/ {print \$1}")
View
6 guest-create
@@ -35,10 +35,16 @@ if [[ "$EUID" -ne 0 ]]; then
show_error "You must be root to run this script. (Hint: use sudo)"
fi
+# TODO: first parameter is hostname but second parameter could be an ip address
+# or a template name, check if it is a valid ip or else search a template
+# with that name, this is a bit tricky but most simple way for users
lxchostname=${1:-undefined}
ipaddr=${2:-undefined}
template_name=${3:-$DEFAULT_TEMPLATE}
+# TODO: assign an empty ip address from network, must not be assigned to any
+# where and must not be used by any closed guest's.
+
template_dir=$TEMPLATES_DIR/$template_name
if [ "$lxchostname" == "undefined" ]; then
View
1 guest-destroy
@@ -1,5 +1,6 @@
#!/bin/bash
name=$1
+# TODO: check is given name is an existing lxc guest
lxc-stop -n $name
rm -f $config /etc/lxc/$name.conf
rm -f $config /etc/lxc/auto/$name.conf
View
2 guest-list
@@ -1,3 +1,5 @@
#!/bin/bash
+# TODO: we should show current state of guest (RUNNING, STOPPED, etc.) and ip
+# address
. /etc/simplelxc
ls $LXCS_DIR/*/config 2>/dev/null | cut -d'/' -f'5'
View
1 guest-login
@@ -1,5 +1,6 @@
#!/bin/bash
name=$1
+# TODO: check if there is an existing lxc and it is in running state
. /etc/simplelxc
ip=$(cat $LXCS_DIR/$name/rootfs/etc/hosts | awk "/$name/ {print \$1}")
ssh -o StrictHostKeyChecking=no -i /etc/ssh/ssh_host_rsa_key root@$ip
View
2 guest-restart
@@ -1,4 +1,6 @@
#!/bin/bash
name=$1
+# TODO: check if a guest with that name exists and already running; if stopped,
+# then show a warning and start
lxc-stop -n $name
lxc-start -n $name -d
View
1 guest-start
@@ -1,3 +1,4 @@
#!/bin/bash
name=$1
+# TODO: check if guest is existing and stopped, else show warning
lxc-start --name $name --daemon
View
1 guest-stop
@@ -1,3 +1,4 @@
#!/bin/bash
name=$1
+# TODO: check if guest is existing and running, else show warning
lxc-stop -n $name
View
3 host-check
@@ -1,5 +1,6 @@
#!/bin/bash
+# TODO: we should move this kind of functions to a file wich we import that file where needed
function show_error {
echo -e "${0##*/}: \E[31m$1" >&2
tput sgr0 >&2
@@ -15,7 +16,7 @@ fi
. /etc/simplelxc
# check dependencies
-if dpkg -l lxc bridge-utils debootstrap iptables iproute | grep "No packages found" &>/dev/null; then
+if dpkg -l lxc bridge-utils debootstrap iptables iproute apt-cacher-ng | grep "No packages found" &>/dev/null; then
show_error "Dependencies failed"
exit 2
fi
View
3 template-chroot
@@ -1,4 +1,7 @@
#!/bin/bash
name=$1
+# TODO: check if template with +name is exists
. /etc/simplelxc
+# TODO: show a warning about "debian runs any installed servise immediately,
+# don't install services in chroot"
chroot $TEMPLATES_DIR/$name
View
3 template-copy
@@ -1,7 +1,10 @@
#!/bin/bash
from=$1
to=$2
+# TODO: check if $from exists and $to does not
. /etc/simplelxc
cp -rap $TEMPLATES_DIR/$from $TEMPLATES_DIR/$to
+# TODO: we should be more strict about templates, may be we should just look
+# how openvz handle this
sed -i "s/template-$from/template-$to/g" $(grep -rl "template-$from" $TEMPLATES_DIR/$to/etc/ 2>/dev/null)
View
6 template-create
@@ -1,9 +1,13 @@
#!/bin/bash
set -e
-. /etc/simplelxc
name=${1:-$DEFAULT_TEMPLATE}
release=${2:-$DEFAULT_TEMPLATE}
+# TODO: check name does not exists
+# TODO: check is releasename is valid
+
+. /etc/simplelxc
+
export LANGUAGE=C
export LC_ALL=C
export LANG=C
View
1 template-destroy
@@ -1,5 +1,6 @@
#!/bin/bash
name=${1:-undefined}
+# TODO: check if given name is an existing template name
. /etc/simplelxc
if [ "$name" == "undefined" ]; then
View
1 template-list
@@ -1,3 +1,4 @@
#!/bin/bash
. /etc/simplelxc
+# TODO: dont list anything in that directory, maybe "grep -l template- $TEMPLATES_DIR/*/etc/hostname"
ls $TEMPLATES_DIR/

0 comments on commit 2971a5a

Please sign in to comment.
Something went wrong with that request. Please try again.