Openwrt Hostname is not permanent - hostname

I am using /etc/config/system file to change the hostname of the openwrt/lede router and after restart using "/etc/init.d/system restart" the name changed successfully. when I reboot the router, the name got changing to "lede", and also my entry in system not available. What is the actual issue here and How to solve this?.
Thanks.

Maybe your file system does not support persistent write-back to flash storage? Do all files get reset after a reboot? Does the entire /etc/config/system file get reset, or is it just just the hostname line that is reverted? Do you use any GUI or automatic tools to make configurations? A clean OpenWrt/LEDE installation does not write to any file in /etc/config/.
Also see: On reboot command router resets Openwrt Caos Calmer 15.05 for more information about problems with persistent write-back, which is most likely your issue.

Related

how to handle it easily when failed to ssh gce due to fstab invalid configuration

On GCE, I added a disk to my VM and changed the fstab file to mount disk automatically. But I made a mistake in that file so I couldn't ssh this vm any more.
In my opinion, I need to edit that file correctly then I can ssh it again. The problem is I couldn't login first to edit it.
Are there some ways to fix this issue?
Using the interactive serial console to revert the changes you might have done.
Refer to this post.
create a root password for the serial console
login into the instance and revert the changes

Vagrant synced file not updating

I have setup a Vagrant box with Ubuntu 12.04 and Apache2 (all very vanilla, as per Vagrant's tutorial). I've been testing it for web development and I stumbled across a weird issue (not sure if bug or feature):
I have setup a synced folder across my machine and the VM folder. Apache has been serving the files mostly well, except (up to now) for a JSON file I'm using.
If I edit it locally, it seemingly syncs it to the VM folder. Both copies are the same.
Although, if I XHR it from the browser after modifying it, I still get the previously served version of that file.
At first, I thought the browser had it cached, but after trying with 2 different browsers (Chrome(ium) and Firefox), after clearing their respective cache, the issue remained.
I finally managed to go around it by reloading (vagrant reload) the VM.
What I was wondering is if this is a bug or a feature and how can I go around it. Is Apache configurable to not cache server side for a specific folder/file/filetype?
vagrant use previous setting until you provision that new setting again, so after every change in vagrant do provision to see reflected output. There is no apache2 cache problem.
For that use command
vagrant reload vmname --provision
if your vm name is default then use
vagrant reload default --provision
it will reboot vagrant vm and apply change to vm .After provision you will be able to see changes.
Finally figured it out. This relates to an issue that occurs with both Apache and /or Nginx: the sendfile option in server configuration.
Basically a new file wasn't being sent/updated client side even when it was changed server-side by Vagrant sync mechanism.
Check this answer for a solution: here.

Is it possible to run more than one rabbitmq instance on one machine?

I want to build a RabbitMQ cluster in my dev machine (windows).
reason is that I would like to test and study it.
Is it possible to run more than one rabbitmq instance on one machine?
I am guessing I need to:
Change the listening port
Change the appdata folder (C:\Users\MyUser\AppData\Roaming)
Change the ui plugin port so I can view all instances.
Remove the service and run from cli
Has anyone tried it?
Is there a known guide?
This thread appears to detail what you need. From the thread responses (scroll down):
The following settings are necessary to separate the node runtimes
completely, while allowing them to share the installed code base.
RABBITMQ_CONFIG_FILE /etc/rabbitmq/rabbitmq
RABBITMQ_MNESIA_BASE /var/lib/rabbitmq/mnesia
RABBITMQ_LOG_BASE /var/log/rabbitmq
RABBITMQ_ENABLED_PLUGINS_FILE /etc/rabbitmq/enabled_plugins
Now the official RabbitMQ documentation contains a section "A Cluster on a Single Machine", which describes how to run multiple Rabbit nodes on a single machine.
See https://www.rabbitmq.com/clustering.html#single-machine
One approach that I took when testing out clustering on my dev machine was to fire up several VMs. I had several for Rabbit and one for HAProxy.
While you can, as per one of the other answers, run multiple instances on a single OS instance, the multiple VM approach allowed me to mimic the intended production environment more closely.
NB. I have chosen to interpret your 'one machine' as meaning a physical machine for the purpose of this answer. If your meaning was 'virtual' then I defer to the other answer posted against this question which details how to accomplish this.
You can run multiple RabbitMQ instances on 1 machine without clustering. You just need to change the ports and the node name in rabbitmq-defaults, rabbitmq-env and config files.
For Linux:
Make sure you have Erlang installed, then download the latest version for Generic Unix and extract it.
Go to rabbit installation folder(the folder you just extracted)/sbin -> open the rabbitmq-defaults file and change SYS_PREFIX=${RABBITMQ_HOME} to create the default folder somewhere else, you should set the path to the extracted folder, for ex. /home/YOUR-USERNAME/rabbit_server-msg(this is my extracted folder).
Change the node name. Open the rabbitmq-env file -> find NODENAME=rabbit#${HOSTNAME} and change the name rabbit (ex. rabbitMSG#${HOSTNAME}). In the same file locate and change DEFAULT_NODE_PORT, by default it’s set to 5672. The default clustering port is set by ${DEFAULT_NODE_PORT} + 20000. So if you set the default node port to 5673, the clustering port will be 25673.
Install the Management Plugin. Navigate to rabbitmq-server/sbin and run “./rabbitmq-plugins enable rabbitmq_management”
The AMQP and HTTP ports need to be chnaged in the config file. Copy the file rabbitmq.config.example and paste it in the rabbit_server-msg(again this is my extracted forlder)/etc(this is the default folder created by RabbitMQ from step 1)/rabbitmq folder, rename the file to just rabbitmq.config. If you can’t find the file rabbitmq.config.example in the rabbit folder create a file named rabbitmq.config and copy the code from their GitHub.
Open the config file and uncomment the following lines:
– {tcp_listeners, [5672]} and change the port number (It is recommended to set the same number as the DEFAULT_NODE_PORT in rabbitmq-env for example 5673).
– {listener, [{port, 12345} and change the port number (This is for the management plugin).
NOTE: Be careful with the commas and brackets. Remove the comma after {tcp_listeners, [5672]}. Also after {listener, [{port, 12345} close the brackets like so ]}. Otherwise when you try to run ./rabbitmq-server it will show errors (It will show you on which line in the config file you have an error so you can fix it).
Now start up the server and log in the manager. Check the Listening ports under Ports and contexts to see if you made the changes. Do this for the other servers and you will be able to run as many servers as you want on 1 machine all with different listening ports. To start the RabbitMQ server automatically when you log in use the Startup Application program.
For Windows:
Setting up RabbitMQ for Windows is preatty much the same as on Linux.
Make sure you have Erlang installed, then download the latest version for Windows and extract it.
Go to rabbit(the folder you just extracted)/sbin -> open the rabbitmq-defaults.bat file and change RABBITMQ_BASE to create the default folder somewhere else, you should set the path to the extracted folder, for ex. C:/rabbit_server-msg(this is my extracted folder).
Change the node name. Open the rabbitmq-env.bat file -> find RABBITMQ_NODENAME=rabbit#!HOSTNAME! and change the name rabbit (ex. rabbitMSG#!HOSTNAME!). In the same file locate and change RABBITMQ_NODE_PORT, by default it’s set to 5672. To change the default clustering port locate and change RABBITMQ_DIST_PORT, by default it’s set to 25672.
Install the Management Plugin. Navigate to rabbit-server/sbin and run “rabbitmq-plugins.bat enable rabbitmq_management”.
The AMQP and HTTP ports need to be chnaged in the config file. Create a file named rabbitmq.config and copy the code from their GitHub. Put the file in your installation folder/RabbitMQ (ex. my config is in C:/rabbit_server-msg/RabbitMQ). Also in the rabbitmq-defaults.bat file check CONFIG_FILE it should be set to CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq.
Open the config file and uncomment the following lines:
– {tcp_listeners, [5672]} and change the port number (It is recommended to set the same number as the RABBITMQ_NODE_PORTin rabbitmq-env for example 5673).
– {listener, [{port, 12345} and change the port number (This is for the management plugin).
NOTE: Be careful with the commas and brackets. Remove the comma after {tcp_listeners, [5672]}. Also after {listener, [{port, 12345} close the brackets like so ]}. Otherwise when you try to run rabbitmq-server.bat it will show errors (It will show you on which line in the config file you have an error so you can fix it).
Now start up the server and log in the manager. Check the Listening ports under Ports and contexts to see if you made the changes. Do this for the other servers and you will be able to run as many servers as you want on 1 machine all with different listening ports.
Source: https://lazareski.com/multiple-rabbitmq-instances-on-1-machine/

Is there a way to check if a directory exists in Apache configuration files?

Is there a way to include configuration settings in Apache based on if a directory exists? Basically I have a portable hard drive that I transport between work and home that has some stuff I'm developing on it. I only want the Apache config to load a particular virtual host if the folder exists.
Since Apache 2.4.34 you can now use <IfFile>...</IfFile> which will check to see if a file exists. There's more details on the <IfFile> page.
No, there seems to be no direct way to do this.
The only thing that might be a solution is the IfDefine directive. You can define defines using the -d parameter to when the server is started.
The parameter-name argument is a define as given on the httpd command line via -Dparameter-, at the time the server was started.
You might be able to check for the existence of a directory in a batch or bash file, and set the -d parameter accordingly.
Whether that is an option, will depend on how your server is started from the portable hard drive.
I've come up with a solution that seems to work for Linux and OS X, and it hinges on "mountpoints". It might be possible to emulate it within Windows, as well, but you would probably have to get creative with FUSE and/or Cygwin.
If you create an empty folder in your home directory, such as "/Users/username/ExtraVhosts", you can add an apache directive to "Include /Users/username/ExtraVhosts/*".
Then, when you insert your thumb drive, you can mount somewhere and then use mountpoint "binding" to cross-link the ExtraVhosts folder to a folder on the mobile device.
An OS X example:
I have a thumb drive called 'Cherrybomb'
When I insert it, it always gets mounted to /Volumes/Cherrybomb
I can then use bindfs (sudo port install bindfs) to mount a subfolder of it, like so:
sudo bindfs /Volumes/Cherrybomb/Projects/vhosts /Users/username/ExtraVhosts
Then I can restart apache to read in the updated configuration:
sudo /opt/local/apache2/bin/apachectl restart
At that point, it's just a matter of adding entries in /etc/hosts for server aliases to get picked up.
The linux equivalent would be using the "--bind" parameter of the mount command.
One caveat: This makes it difficult to quickly unmount the USB drive, since it is always marked as "in use" by apache. Here's a removal procedure:
Close all open files and terminal sessions that are using the drive (the present-working-directory in terminal can cause unmount issues)
Stop apache: sudo /opt/local/apache2/bin/apachectl stop
umount /Users/username/ExtraVhosts
Then you can either unmount it graphically or manually (umount /Volumes/Cherrybomb).
If your work and home machines mount the drive to different locations, you could have multiple vhosts folders - home_vhost, work_vhost, etc - and use that in the binding step.
I hope this helps someone out :)
If you point apache to the mountpoint only there shouldn't be an issue. Just don't point Directory directives to directories within the drive.
eg, if you mount /dev/somedisk /mnt/somevhost, the
/mnt/somevhost directory will be there whether or not you have the drive mounted and apache will start. Apache doesn't care if the directory is empty so a <Directory "/mnt/somevhost"/> won't cause server to not start if the drive isn't mounted.
Work with UNIX not against it :-p This solution should be sufficient for development.

Is it possible to have WAMP run httpd.exe as user [myself] instead of local SYSTEM?

I run a django application over apache with mod_wsgi, using WAMP.
A certain URL allows me to stream the content of image files, the paths of which are stored in database.
The files can be located whether on local machine or under network drive (\\my\network\folder).
With the development server (manage.py runserver), I have no trouble at all reading and streaming the files.
With WAMP, and with network drive files, I get a IOError : obviously because the httpd instance does not have read permission on said drive.
In the task manager, I see that httpd.exe is run by SYSTEM. I would like to tell WAMP to run the server as [myself] as I have read and write permissions on the shared folder. (eventually, the production server should be run by a 'www-admin' user having the permissions)
Mapping the network shared folder on a drive letter (Z: for instance) does not solve this at all.
The User/Group directives in httpd.conf do not seem to have any kind of influence on Apache's behaviour.
I've also regedited : I tried to duplicate the HKLM\[...]\wampapache registry key under HK_CURRENT_USER\ and rename the original key, but then the new key does not seem to be found when I cmd this
> httpd.exe -n wampapache -k start
or when I run WAMP.
I've run out of ideas :)
Has anybody ever had the same issue?
Win+R, services.msc
edit wampapache and wampmysqld to log on as some user.
the tray icon is a convenient front end to "net start wampapache" and "net start wampmysqld"
The User/Group directives in httpd.conf do not seem to have any kind of influence on Apache's behaviour.
httpd.exe is started by the root user (this is probably why you see it running under SYSTEM). The user and group lines in httpd.conf determine what user the child processes (that httpd spawns) will run under. These forks are what actually handle page requests, etc. so it is possible that your configuration is already doing what you want it to, it is just unclear from looking at task manager.
You could also try using runas to start WAMP/Apache, though your mileage may vary.
I've just found that executing httpd.exe myself works for me... I just loose all the funky WAMP tray icon, and the "restart apache" menu item, really handy whenever I update my application code...
I'll have to make do with this for the moment...