Hi, I'm a freshman, and use Op from 2017.Sorry,my english is poor.
I have a homelab installed Virtual Machine,and deploy Openwrt x86.
Now I try to setup keepalived,but it'not working properly.
The problem is similar to this post([Keepalived setup - where to put config?]).And wulfy23's reply is useless.
Especially on x86, there is no reason to use an outdated/ obsolete/ unsupported version of OpenWrt, please give 19.07.7 or 21.02.0-rc1 a test, which fix important security issues and increase the chances that others can help you.
/etc/keepalived/keepalived.conf is where config is read from by default.
AFAIK, you shouldn't have to modify anything in /etc/config after installing the package; except to enable/start the service after you write the config file.
Thanks, I updated the wiki to mention alt_config_file
That's a pretty gnarly init script.
It's almost as if someone wanted to build a luci ui on top and expose all the keepalived options as UCI options (there's so much), but then they didn't and we ended up with two complicated configs - one in UCI and one that comes with the tool.
Thanks for your reply.
I have downloaded keepalived.init. keepalived.init is the same as /etc/init.d/keepalived in my openwrt.
I try to ln -s /etc/keepalived/keepalived.conf /tmp/keepalived.conf,and it's failed.
I read keepalived.conf
process_config() {
local alt_config_file linkbeat_use_polling
rm -f "$KEEPALIVED_CONF"
# First line
printf '! Configuration file for keepalived (autogenerated via init script)\n' > "$KEEPALIVED_CONF"
printf '! Written %s\n\n' "$(date +'%c')" >> "$KEEPALIVED_CONF"
[ -f /etc/config/keepalived ] || return 0
config_load 'keepalived'
config_get alt_config_file globals alt_config_file
# If "alt_config_file" specified, use that instead
[ -n "$alt_config_file" ] && [ -f "$alt_config_file" ] && {
rm -f "$KEEPALIVED_CONF"
# Symlink "alt_config_file" since it's a bit easier and safer
ln -s "$alt_config_file" "$KEEPALIVED_CONF"
return 0
}
config_get_bool linkbeat_use_polling globals linkbeat_use_polling 0
[ "$linkbeat_use_polling" -gt 0 ] && printf 'linkbeat_use_polling\n\n' >> "$KEEPALIVED_CONF"
config_section_open "global_defs"
config_foreach_wrapper globals
config_section_close
config_section_open "static_ipaddress"
config_foreach_wrapper static_ipaddress
config_section_close
config_section_open "static_routes"
config_foreach_wrapper static_routes
config_section_close
config_foreach_wrapper vrrp_script
config_foreach_wrapper vrrp_sync_group
config_foreach_wrapper vrrp_instance
config_foreach_wrapper virtual_server
return 0
}
/tmp/keepalived.conf is created by this code,and it's blank as 1/6.Then,the others codes is over my head.
Now I'm ban init.d/keepalived,and add /usr/sbin/keepalived -f -n /etc/keepalived/keepalived.conf.
config_get alt_config_file ... reads /etc/config/keepalived value
These lines
[ -n "$alt_config_file" ] && [ -f "$alt_config_file" ] && {
rm -f "$KEEPALIVED_CONF"
# Symlink "alt_config_file" since it's a bit easier and safer
ln -s "$alt_config_file" "$KEEPALIVED_CONF"
return 0
}
Make it so that if alt_config_file is specified and exists the /tmp/keepalived.conf is deleted, a symlink is created where it was before, and init script exits
You can try adding echo alt config fille is "$alt_config_file" > /dev/stderr && exit 1 statements right before those lines, and then run the script. The script will then fail, but will print some stuff out that tells you two things... a) script made it to your lines, and b) it'll tell you the parsed value.
You can move that to other places and replace variable name with other stuff you want to print out.
It sounds like there's a typo or a weird bug somewhere.
# If "alt_config_file" specified, use that instead
echo alt config fille is "$alt_config_file" > /dev/stderr && exit 1
[ -n "$alt_config_file" ] && [ -f "$alt_config_file" ] && {
rm -f "$KEEPALIVED_CONF"
# Symlink "alt_config_file" since it's a bit easier and safer
ln -s "$alt_config_file" "$KEEPALIVED_CONF"
return 0
}
I run it and /dev/stderr
alt config fille is
I read /etc/config/luci,find file path use single quotation marks.So I replace this file -- /etc/config/keepalived
Hi, i'm back.
Now, i delete the config of keepalived, and update keepalived from opkg.
So the version of keepalived is 2.2.2-1,and it work well.
Thanks for all of help.