How can i link the mounted folder to Laravel project? - linux

I have a Laravel project, which placed here:
/home/user/www/example.com
We attached a new storage to vds and mounted it for
/home/user/www/storage
folder.
After that we need add symbolic link from
/home/user/www/storage to /home/user/www/example.com/storage
, but we can not do it, because the last one is already exists and contains needed files.
How can we link it for more space to storage folder in the project?
terminal output:
ln -s /home/user/www/storage /home/user/www/example.com/
ln: failed to create symbolic link '/home/user/www/example.com/storage': File exists

Option 1
You can link it to another place inside the storage folder and create a separate disk
$ ln -s /home/user/www/storage/more-space /home/user/www/example.com/
Inside your config/filesystem.php you can add an additional disk
// config/filesystem.php
'disks' => [
'more-space' => [
'local' => [
'driver' => 'local',
'root' => storage_path('more-space'),
],
]
]
and work with it Storage::disk('more-space').
Option 2
You move everything that is inside your current storage folder into your new folder /home/user/www/example.com/
Remove your storage folder with rm -rf /home/user/www/storage
Symlink the new folder ln -s /home/user/www/storage /home/user/www/example.com/

Related

How to generate jhipster application into a different directory?

When I run the following in jhipster-generator's /cli directory:
cd cli
node jhipster.js
I'm generating the application in the same directory (cli). How would I change this directory to somewhere else? For example, export all the generated files into a specific directory.
I believe the directory has something to do with this line of code in jhipster.js:
const localCLI = require.resolve(path.join(process.cwd(), 'node_modules', 'generator-jhipster', 'cli', 'cli.js'));
Note: I'm not running the application with "jhipster" command.

Can I create symbolic links from a Yocto recipe for a file that doesn't exist yet

I am running Yocto Pyro, and I am trying to create a recipe that creates a symlink to an area that will be mounted at runtime. We are mounting our secondary storage at /var/local in the fstab. I would like to store the network settings there since the rootFS gets wiped out when we do firmware upgrade of our devices.
This is the recipe I am working on.
DESCRIPTION = "Create links to the persistent storage area for the network files."
PRIORITY = "optional"
LICENSE = "CLOSED"
FILES_${PN} += "/etc /etc/systemd/network"
S = "${WORKDIR}"
do_install() {
ln -frs /var/local/network/hostname ${D}/hostname
ln -frs /var/local/network/eth0.network ${D}/etc/systemd/network/eth0.network
# ln -frs /var/local/network/sysctl.conf ${D}/etc/sysctl.conf
# ln -frs /var/local/network/iptables-config ${D}/etc/sysconfig/iptables-config
}
The error I am getting is that it is failing to create the symbolic link.
| ln: failed to create symbolic link '/home/gen-ccm-root/workdir/tools/poky/build-dev/tmp/work/armv7ahf-neon-poky-linux-gnueabi/network-links/1.0-r0/image/etc/systemd/network/eth0.network': No such file or directory
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_install (log file is located at /home/gen-ccm-root/workdir/tools/poky/build-dev/tmp/work/armv7ahf-neon-poky-linux-gnueabi/network-links/1.0-r0/temp/log.do_install.118559)
ERROR: Task (/home/gen-ccm-root/workdir/tools/poky/meta-markem-imaje-private-bsp/recipes-core/network-links/network-links_1.0.bb:do_install) failed with exit code '1'
NOTE: Tasks Summary: Attempted 2805 tasks of which 2796 didn't need to be rerun and 1 failed.
Summary: 1 task failed:
/home/gen-ccm-root/workdir/tools/poky/meta-markem-imaje-private-bsp/recipes-core/network-links/network-links_1.0.bb:do_install
Is there a way to make the links? Or do I need to take a different approach of reading the files at bootup and copying them in or something of that nature? I do believe that the security team will eventually want to make the root filesystem read only, so links are preferred to modifying the RootFS at startup.
You might want to do that via extending base-files recipe via a bbappend
base-files_%.bbappend
do_install_append() {
...
}
What we do is create a postinstall function in .inc file in our image folder.
ROOTFS_POSTPROCESS_COMMAND += " symlinkfunction "
symlinkfunction() {
ln -s /path/on/target "${IMAGE_ROOTFS}/path/in/rootfs"
}
Use the .inc file in any image file that creates your target and it will update the target root file system with a new symlink.

Capistrano deployment with Amazon EFS (bind mounted folders) failing when using with :linked_dirs

I am having an issue trying to use Capistrano to deploy an application that requires having several Amazon EFS bind mounts inside of the deployment (current) folder.
I have a directory on the webserver in the root called /webroot inside of it is where all of our code currently is along with about 7 folders (bind mounts) that are shared across three nodes.
Inside of my deploy.rb I have the following line set :deploy_to, "/webroot/testingCap" in which Capistrano is deploying the code into the symlinked folder current. This is great but now when it gets to the step of symlinking the bind mount directories for example:/webroot/uploads it throws an error:
rm -rf /webroot/uploads
rm: cannot remove '/webroot/uploads'
Device or resource busy
I am not sure why it is trying to forcefully remove that directory? I thought it was supposed to just symlink to the directory.
My linked_dirs part looks like this inside of deploy.rb:
append :linked_dirs, "/webroot/uploads"
What am I doing wrong?
:linked_dirs only works with relative paths and always uses Capistrano's shared directory.
When you add e.g. "foo" to :linked_dirs, Capistrano will create a symlink within your deployed app. If anything already exists there, it will delete it first (that is why you are seeing the rm -rf).
The destination of that link will always be to the same name in Capistrano's shared directory. So the chain of events will be like this:
rm -rf /webroot/testingCap/current/foo
ln -s /webroot/testingCap/shared/foo /webroot/testingCap/current/foo
Thus if you look inside current, you will a link that points
foo -> /webroot/testingCap/shared/foo
Notice that the path relative to current is identical to the path relative to shared. This is how :linked_dirs works and you can't change it.
For example, if your app expects to store uploads in public/uploads, you will need the exact same relative path to exist inside shared in order for the link to be established. In other words, the link will point like this:
/webroot/testingCap/current/public/uploads -> /webroot/testingCap/shared/public/uploads
In your case, I suspect you can get this to work, but you'll need to make sure that your mount points are located exactly where Capistrano expects them to be.

symlink from public_html_source to public_html

i'm trying to create a symlink between 2 folders on a server that has limited access so I can "deploy" my site.
This is the path to the git repo /home2/username/public_html_source and in there there is a folder named backend_code Instead of ftp uploading the files of backend_code into /home2/username/public_html, I would like to make a link to it.
I tried using ln but I keep getting a symlink folder inside of public_html.
So i'm trying to get
/home2/username/public_html
to point to
/home2/username/public_html_source/backend_code
First remove the /home2/username/public_html folder (after backing it up).
rm -R /home2/username/public_html
Then apply
ln -s /home2/username/public_html_source/backend_code /home2/username/public_html
If I'm not mistaken you'd can't link two folders already existing.
What i'd do is save the data in backend_code and then make a symlink.
ln -s /home2/username/public_html_source/backend_code /home/username/public_html
This should create a symlink called backend_code in side of public_html_source which links to /home/username/public_html
HTH
This solution works even if you don't have root privileges of server or using shared hosting...
Step:1 :: Change your config/filesystems.php
From
'links' => [
public_path('storage') => storage_path('app/public'),
],
To
'links' => [
base_path('public_html/storage') => storage_path('app/public'),
],
Step:2 :: Connect to SSH & Run the following commands
$ php artisan optimize
$ php artisan storage:link
$ php artisan optimize
it should work now.

Two different project in one git repo

I'm fairly new to GIT and I'm trying to figure out if I can do as follow,
I'm developing an app which has a front-end and a back-end.
Let's say the front-end contains 10 files located in this path.
Eg:
/home/front_end/file1 , /home/front_end/file2 ...... /home/front_end/file10
While, the back-end contains 100 files located in a different path.
Eg:
/home/app/code/file1, /home/app/code/file2 ,................./home/app/code/file99
How can I create a repo which has two different locations?
You can't really.
What you can do is:
setting up a repo wherever you want, with 'front_end' and 'app_code' folders in it
symlink /home/font_end to yourRepo/front_end
(as in ln -s /path/to/yourRepo/font_end /home/front_end)
symlink /home/app/code to yourRepo/app_code
(as in ln -s /path/to/yourRepo/app_code /home/app/code)

Resources