Browse Source

miaou-create locale fixed

main
pvincent 7 days ago
parent
commit
4f6117d177
  1. 39
      bin/pct-create
  2. 1
      result
  3. 17
      tools/miaou-create

39
bin/pct-create

@ -20,19 +20,19 @@ function usage {
function parse_options { function parse_options {
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
--help | -h)
usage && exit 0
;;
--no-start)
START=false
;;
*)
if [[ -z $CONTAINER_NAME ]]; then
CONTAINER_NAME=$1
else
echo >&2 "Unknown option: $1" && usage && exit 2
fi
;;
--help | -h)
usage && exit 0
;;
--no-start)
START=false
;;
*)
if [[ -z $CONTAINER_NAME ]]; then
CONTAINER_NAME=$1
else
echo >&2 "Unknown option: $1" && usage && exit 2
fi
;;
esac esac
shift 1 # Move to the next argument shift 1 # Move to the next argument
@ -77,7 +77,7 @@ function create_container {
local vol_in_gb=$(convert_human_size_to_gigabyte $STORAGE_SIZE) local vol_in_gb=$(convert_human_size_to_gigabyte $STORAGE_SIZE)
local mem_in_mb=$(convert_human_size_to_megabyte $MEMORY) local mem_in_mb=$(convert_human_size_to_megabyte $MEMORY)
local swp_in_mb=$(convert_human_size_to_megabyte $SWAP) local swp_in_mb=$(convert_human_size_to_megabyte $SWAP)
pct create \ pct create \
$new_id \ $new_id \
$template_file \ $template_file \
@ -92,15 +92,15 @@ function create_container {
--onboot true \ --onboot true \
$(optional_public_keys) \ $(optional_public_keys) \
--unprivileged true \ --unprivileged true \
--features nesting=1 \
--features nesting=1
[[ -n $TAG_NAME ]] && pct set $new_id --tags $TAG_NAME [[ -n $TAG_NAME ]] && pct set $new_id --tags $TAG_NAME
echo "container: $CONTAINER_NAME succesfully created with vmid=$new_id!" echo "container: $CONTAINER_NAME succesfully created with vmid=$new_id!"
} }
function existing_container { function existing_container {
local vmid=$($BASEDIR/pct-lookup "$CONTAINER_NAME" 2>/dev/null) local vmid=$($BASEDIR/pct-lookup "$CONTAINER_NAME" 2>/dev/null)
if [[ -z $vmid ]]; then
if [[ -z $vmid ]]; then
false false
else else
echo "container $CONTAINER_NAME already exists with vmid=$vmid!" echo "container $CONTAINER_NAME already exists with vmid=$vmid!"
@ -111,9 +111,6 @@ function existing_container {
# MAIN # MAIN
set -Eue set -Eue
parse_options $*
parse_options "$@"
source "$CONFIG_FILE" source "$CONFIG_FILE"
existing_container && false || create_container existing_container && false || create_container

1
result

@ -1 +0,0 @@
State: RUNNING

17
tools/miaou-create

@ -42,9 +42,20 @@ function before_start {
function after_start { function after_start {
# hot changes # hot changes
pct exec "$CONTAINER_ID" -- apt-get purge -y postfix
pct exec "$CONTAINER_ID" -- apt-get update
pct exec "$CONTAINER_ID" -- apt-get install -y file git bc vim jq sudo bash-completion
pct push $CONTAINER_ID <(
cat <<'EOF'
en_US.UTF-8 UTF-8
EOF
) /etc/locale.gen
pct exec "$CONTAINER_ID" -- locale-gen >/dev/null
pct exec "$CONTAINER_ID" -- bash <<EOF
echo -n 'updating...'
apt-get update >/dev/null
echo DONE
apt-get purge -y postfix
apt-get install -y file git bc vim jq sudo bash-completion
EOF
if [[ -v MIAOU_BASH_DIR ]]; then if [[ -v MIAOU_BASH_DIR ]]; then
pct exec "$CONTAINER_ID" -- /opt/miaou-bash/init.sh pct exec "$CONTAINER_ID" -- /opt/miaou-bash/init.sh
fi fi

Loading…
Cancel
Save