summaryrefslogtreecommitdiff
path: root/user-init
blob: 1857534a5fbccd1bbe6f44d0f022baa72ef29c47 (plain)
  1. #!/bin/sh
  2. set -e
  3. # reset flags
  4. apache_reload_needed=""
  5. runmode="normal"
  6. # subfolder name defaults (edit /etc/local/users.conf to override)
  7. mac="mac" # Optimized for sharing through AppleShare (netatalk)
  8. pc="pc" # Optimized for sharing though SMB/CIFS (Samba)
  9. xchange="xchange" # Readable by group
  10. # config (edit /etc/local/users.conf to override)
  11. # which are user accounts (adduser values are used if empty)
  12. first_uid=""
  13. last_uid=""
  14. do_quota="no" # Manage disk quota
  15. do_distrib="no" # Distributed shares (software archive)
  16. do_personal="no" # Personal shares (mac, pc, public_html)
  17. do_xchange="no" # Group-readable shares
  18. do_public="no" # Public share (web homepage)
  19. do_mac="no" # AppleShare-optimized share (netatalk)
  20. do_pc="no" # SMB-ptimized share (Samba)
  21. do_server="no" # Personal share on remote SMB server
  22. quota_roots="" # space-delimited list of disk devices
  23. quota_soft="100000"
  24. quota_hard="1000000"
  25. quota_newstyle="yes" # Woody used a different syntax...
  26. xchange_root="xchange"
  27. xchange_sharedroot="/home/XCHANGE"
  28. mac_root="mac"
  29. pc_root="pc"
  30. server_name="SERVER" # SMB name of remote server
  31. server_desc="remote server"
  32. server_root="server"
  33. server_conf="/etc/security/pam_mount.conf"
  34. server_userconf=".winpassword"
  35. QUOTASOFT="0"
  36. QUOTAHARD="0"
  37. ### No servicable parts below this line! ###
  38. if [ -e /etc/adduser.conf ]; then
  39. . /etc/adduser.conf
  40. else
  41. echo "/etc/adduser.conf missing. Exiting..."
  42. exit 1
  43. fi
  44. [ -r /etc/local/users.conf ] && . /etc/local/users.conf
  45. #TODO: Add conversion like below, and change remaining script to new variable names
  46. #[ -n "$XDIR" ] && xchange_sharedroot="$XDIR"
  47. # exit silently if this system lacks required hints
  48. [ -r /etc/local/volumes ] && . /etc/local/volumes || exit 0
  49. XDIRREAL="$XDIR/users/root"
  50. if [ -n "$XCHANGE" ]; then
  51. if [ ! -d "$XDIR" ]; then
  52. echo "XDIR doesn't exist. Ignoring XCHANGE!"
  53. XCHANGE=""
  54. fi
  55. fi
  56. if [ $# -gt 0 ]; then
  57. USERS=$*
  58. else
  59. # USERS=`getent passwd | awk -F: '{print $1}'`
  60. echo "uid required!"
  61. exit 1
  62. fi
  63. [ -n "$NETATALK_HOME" ] && mac="$NETATALK_HOME"
  64. [ -n "$SAMBA_HOME" ] && pc="$SAMBA_HOME"
  65. [ -n "$XCHANGE_HOME" ] && xchange="$XCHANGE_HOME"
  66. echo "Setting up additional folders and permissions..."
  67. for user in $USERS; do
  68. uid="`getent passwd \"$user\" | awk -F: '{print $3}' | head -n 1`"
  69. HOME="`getent passwd \"$user\" | awk -F: '{print $6}' | head -n 1`"
  70. groups="`groups \"$user\"`"
  71. if [ -z "$HOME" ]; then
  72. echo "User $user doesn't exist. Ignoring..."
  73. continue
  74. fi
  75. # Ignore non-human accounts silently
  76. [ "$uid" -ge "$FIRST_UID" -a "$uid" -le "$LAST_UID" ] || continue
  77. [ -d "$HOME" ] || continue
  78. # [ -L "$HOME" ] && continue
  79. echo -n "$user"
  80. # if [ -x /etc/local/quota.sh ]; then
  81. # /etc/local/quota.sh "$user"
  82. # fi
  83. quotasoft="$QUOTASOFT"
  84. quotahard="$QUOTAHARD"
  85. for quotaoverride in $QUOTAOVERRIDES; do
  86. for group in $groups; do
  87. if [ "$quotaoverride" = "$group" ]; then
  88. eval quotasoft=\"\$QUOTASOFT_${quotaoverride}\"
  89. eval quotahard=\"\$QUOTAHARD_${quotaoverride}\"
  90. continue
  91. fi
  92. done
  93. done
  94. for quotahome in $QUOTAHOMES; do
  95. if [ -n "$NEW_QUOTA" ]; then
  96. setquota "$user" "$quotasoft" "$quotahard" 0 0 "$quotahome"
  97. else
  98. setquota "$user" "$quotahome" "$quotasoft" "$quotahard" 0 0
  99. fi
  100. done
  101. if [ -n "$NETATALK" ]; then
  102. mkdir -p "$HOME/$mac"
  103. fi
  104. if [ -n "$SAMBA" ]; then
  105. mkdir -p "$HOME/$pc"
  106. fi
  107. if [ -n "$XCHANGE" ]; then
  108. mkdir -p "$XDIRREAL/$user"
  109. fi
  110. if [ -n "$PUBLIC" ]; then
  111. mkdir -p "$HOME/public_html"
  112. fi
  113. #TODO: Enable this only when option implemented to do it non-interactively
  114. # echo # dirty hack: better if being able to lower verbosity of localuserconfig
  115. # su -s /bin/bash -c localuserconfig "$user"
  116. if [ "$do_server" = "yes" ] && [ -r "$server_conf" ] && [ -f "$HOME/$server_userconf" ]; then
  117. server_username="$(grep '^username' \"$HOME/$server_userconf\" | awk -F= '{print $2}' | head -n 1 | awk '{print $1}')"
  118. if [ -n "$server_username" ]; then
  119. if grep -q "^volume $user " "$server_conf"; then
  120. perl -pi -e "s|^volume $user .*|volume $user smb $server_name $server_username $HOME/$server_root uid=$user,gid=$user - -|" "$server_conf"
  121. else
  122. echo "volume $user smb $server_name $server_username $HOME/$server_root uid=$user,gid=$user - -" >> "$server_conf"
  123. fi
  124. fi
  125. fi
  126. chown "$user": "$HOME"
  127. chmod u=rwX,go=rX "$HOME"
  128. # Mail handling
  129. maildir="$MAILDIR"
  130. if [ -f "$HOME/.procmailrc" ]; then
  131. # Drop simple maildir-enabling procmail file when default
  132. if [ -n "$MAILDIR" ] && [ "`md5sum \"$HOME/.procmailrc\" | awk '{print $1}'`" = "03ea802caaa5ce6f2a9be8d56eaf8ff5" ]; then
  133. rm "$HOME/.procmailrc"
  134. else
  135. chown "$user": "$HOME/.procmailrc"
  136. chmod 0640 "$HOME/.procmailrc"
  137. # Check if this one account exceptionally uses maildir
  138. if [ -z "$maildir" ] && egrep -q '^DEFAULT=\$HOME/Maildir/$' "$HOME/.procmailrc"; then
  139. maildir="yes"
  140. fi
  141. fi
  142. fi
  143. if [ -n "$maildir" ]; then
  144. mkdir -p "$HOME/Maildir/cur" "$HOME/Maildir/new" "$HOME/Maildir/tmp"
  145. chown -R "$user": "$HOME/Maildir"
  146. chmod -R u=rw,go=,u+X "$HOME/Maildir"
  147. else
  148. mkdir -p "$HOME/mail"
  149. if [ -n "$USE_MBOX" ]; then
  150. touch "$HOME/mail/mbox"
  151. elif [ -f "$HOME/mail/mbox" ] && [ ! -s "$HOME/mail/mbox" ]; then
  152. rm -f "$HOME/mail/mbox"
  153. fi
  154. chown -R "$user": "$HOME/mail"
  155. chmod -R u=rw,go=,u+X "$HOME/mail"
  156. if [ -f "$HOME/.mailboxlist" ]; then
  157. chown "$user": "$HOME/.mailboxlist"
  158. chmod 0640 "$HOME/.mailboxlist"
  159. fi
  160. fi
  161. mailspool="/var/spool/mail"
  162. if [ -d "/var/mail" ]; then
  163. mailspool="/var/mail"
  164. fi
  165. if [ -f "$mailspool/$user" ]; then
  166. if [ -n "$maildir" ] && [ ! -s "$mailspool/$user" ]; then
  167. rm "$mailspool/$user"
  168. else
  169. chown "$user":mail "$mailspool/$user"
  170. chmod ug=rw,o= "$mailspool/$user"
  171. fi
  172. fi
  173. if [ -f "$HOME/.forward" ]; then
  174. chown "$user": "$HOME/.forward"
  175. chmod 0640 "$HOME/.forward"
  176. fi
  177. # MySQL handling
  178. if [ -f "$HOME/.my.cnf" ]; then
  179. chown "$user": "$HOME/.my.cnf"
  180. chmod 0600 "$HOME/.my.cnf"
  181. fi
  182. # Mac dir permissions
  183. if [ -d "$HOME/$mac" ]; then
  184. chown -R "$user": "$HOME/$mac"
  185. chmod -R u=rw,g=r,o=,ug+X "$HOME/$mac"
  186. rm -rf "$HOME/$mac/Network Trash Folder"
  187. mkdir "$HOME/$mac/Network Trash Folder"
  188. chown nobody: "$HOME/$mac/Network Trash Folder"
  189. chmod a= "$HOME/$mac/Network Trash Folder"
  190. fi
  191. # PC dir permissions
  192. if [ -d "$HOME/$pc" ]; then
  193. chown -R "$user": "$HOME/$pc"
  194. chmod -R u=rw,g=r,o=,ug+X "$HOME/$pc"
  195. fi
  196. #FIXME: something is wrong with prefixing "x" here...
  197. # Exchange dir permissions
  198. if [ -d "$XDIRREAL/$user" ]; then
  199. chown -R "$user":users "$XDIRREAL/$user"
  200. chmod -R g=r,g+X "$XDIRREAL/$user"
  201. if [ -e "x$HOME/$xchange" ]; then
  202. if [ -L "x$HOME/$xchange" ]; then
  203. ln -sf "$XDIRREAL/$user $HOME/$xchange"
  204. else
  205. echo "ERROR: \"$HOME/$xchange\" exists already. Leaving it as is..."
  206. fi
  207. else
  208. ln -s "$XDIRREAL/$user" "$HOME/$xchange"
  209. fi
  210. fi
  211. # Public dir permissions
  212. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./public\(_.*\)?'`; do
  213. chown -R "$user": "$HOME/$dir"
  214. chmod -R u+rX,go=r,go+X "$HOME/$dir"
  215. if [ -n "$NETATALK" ]; then
  216. rm -rf "$HOME/$dir/Network Trash Folder"
  217. mkdir "$HOME/$dir/Network Trash Folder"
  218. chown nobody: "$HOME/$dir/Network Trash Folder"
  219. chmod a= "$HOME/$dir/Network Trash Folder"
  220. fi
  221. done
  222. # Shared dirs are writable by own primary group
  223. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./shared\(_.*\)?'`; do
  224. chgrp -R "$user" "$HOME/$dir"
  225. chmod -R ug=rw,o=,ug+X,g+s "$HOME/$dir"
  226. if [ -n "$NETATALK" ]; then
  227. rm -rf "$HOME/$dir/Network Trash Folder"
  228. mkdir "$HOME/$dir/Network Trash Folder"
  229. chown nobody: "$HOME/$dir/Network Trash Folder"
  230. chmod a= "$HOME/$dir/Network Trash Folder"
  231. fi
  232. done
  233. # Private dirs are readable by own primary group
  234. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./private\(_.*\)?$'`; do
  235. chown -R "$user": "$HOME/$dir"
  236. chmod -R u+rX,g=r,g+X,o= "$HOME/$dir"
  237. done
  238. # Secret dirs are accessible only by self
  239. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./secret\(_.*\)?$'`; do
  240. chown -R "$user": "$HOME/$dir"
  241. chmod -R u+rX,go= "$HOME/$dir"
  242. done
  243. # Fileshares: <home>/shares.<sharetype>/<rogroup>/<rwgroup>/<sharename>
  244. # <sharetype>: Either mac or win depending on which of netatalk and samba provides r/w access to the shares
  245. # <rwgroup>: Group with write access to the share (usually the default group of the owner)
  246. # <rogroup>: Either rwgroup or secondary group with read-only access to the share
  247. # owner and rwgroup members must be member of both groups
  248. #FIXME: Use the below instead, and replace occurrences of "$thisdir" with "$HOME/$dir".
  249. #for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./shares\..*'`; do
  250. find "$HOME" -mindepth 1 -maxdepth 1 -type d -print | egrep "^$HOME/shares\." | (while read thisdir; do
  251. sharetype="`basename \"$thisdir\" | awk -F. '{print $2}'`"
  252. # Define dir and file exceptions
  253. case "$sharetype" in
  254. mac)
  255. dirs_world_rw_create='.AppleDB'
  256. dirs_group_rw_create='.AppleDesktop/Temporary Items/TheFindByContentFolder'
  257. dirs_group_ro_create='TheVolumeSettingsFolder'
  258. dirs_group_ro_update='.AppleDouble'
  259. files_group_ro_update=':2eDS_Store'
  260. dirs_no_access_purge='Network Trash Folder'
  261. ;;
  262. win)
  263. ;;
  264. *)
  265. continue
  266. ;;
  267. esac
  268. exceptions="$dirs_world_rw_create/$dirs_group_rw_create/$dirs_group_ro_create/$dirs_group_ro_update/$files_group_ro_update/$dirs_no_access_purge"
  269. exception_dirs_create="$dirs_world_rw_create/$dirs_group_rw_create/$dirs_group_ro_create"
  270. # <home>/shares.<sharetype>
  271. chown "$user": "$thisdir"
  272. chmod a=rX "$thisdir"
  273. find "$thisdir" -mindepth 1 -maxdepth 1 -type d -print | (while read thisdir; do
  274. # <home>/shares.<sharetype>/<rogroup>
  275. rogroup="`basename \"$thisdir\"`"
  276. chown "$user":"$rogroup" "$thisdir"
  277. chmod ug=rX,o= "$thisdir"
  278. find "$thisdir" -mindepth 1 -maxdepth 1 -type d -print | (while read thisdir; do
  279. # <home>/shares.<sharetype>/<rogroup>/<rwgroup>
  280. rwgroup="`basename \"$thisdir\"`"
  281. chown "$user":"$rwgroup" "$thisdir"
  282. chmod a=rX,g+s "$thisdir"
  283. find "$thisdir" -mindepth 1 -maxdepth 1 -type d -print | (while read thisdir; do
  284. # <home>/shares.<sharetype>/<rogroup>/<rwgroup>/<sharename>
  285. sharename="`basename \"$thisdir\"`"
  286. chown "$user":"$rwgroup" "$thisdir"
  287. chmod u=rw,go=r,a+X,g+s "$thisdir"
  288. ifs="$IFS"
  289. # Set default permissions
  290. find "$thisdir" -mindepth 1 -maxdepth 1 -print | (while read thisitem; do
  291. # <home>/shares.<sharetype>/<rogroup>/<rwgroup>/<sharename>/*
  292. thisparentdir="`basename \"$thisitem\"`"
  293. IFS="/"; for exception in $exceptions; do IFS="$ifs";
  294. if [ "$thisparentdir" = "$exception" ]; then
  295. continue 2
  296. fi
  297. done
  298. chgrp -R "$rwgroup" "$thisitem"
  299. chmod -R ug=rw,o=r,a+X,g+s "$thisitem"
  300. done)
  301. # Handle exception dirs to be created if not existing
  302. IFS="/"; for dir in $exception_dirs_create; do IFS="$ifs";
  303. if [ ! -d "$thisdir/$dir" ]; then
  304. rm -f "$thisdir/$dir"
  305. fi
  306. if [ ! -e "$thisdir/$dir" ]; then
  307. mkdir "$thisdir/$dir"
  308. fi
  309. chown "$user":"$rwgroup" "$thisdir/$dir"
  310. done
  311. IFS="/"; for dir in $dirs_world_rw_create; do IFS="$ifs";
  312. if [ "$rogroup" = "$rwgroup" ]; then
  313. chmod -R ug=rw,o=r,a+X,g+s "$thisdir/$dir"
  314. else
  315. chmod -R a=rw,a+X,g+s "$thisdir/$dir"
  316. fi
  317. done
  318. IFS="/"; for dir in $dirs_group_rw_create; do IFS="$ifs";
  319. chmod -R ug=rw,o=r,a+X,g+s "$thisdir/$dir"
  320. done
  321. IFS="/"; for dir in $dirs_group_ro_create; do IFS="$ifs";
  322. chmod -R u=rw,go=r,a+X,g+s "$thisdir/$dir"
  323. done
  324. # Handle exception dirs to be updated if already there
  325. IFS="/"; for dir in $dirs_group_ro_update; do IFS="$ifs";
  326. if [ -e "$thisdir/$dir" ]; then
  327. chmod u=rw,go=r,a+X,g+s "$thisdir/$dir"
  328. fi
  329. done
  330. # Handle exception files to be updated if already there
  331. IFS="/"; for file in $files_group_ro_update; do IFS="$ifs";
  332. if [ -e "$thisdir/$file" ]; then
  333. chmod u=rw,go=r,g+s "$thisdir/$file"
  334. fi
  335. done
  336. # Handle exception dirs to be purged and recreated
  337. IFS="/"; for dir in $dirs_no_access_purge; do IFS="$ifs";
  338. rm -rf "$thisdir/$dir"
  339. mkdir -m a= "$thisdir/$dir"
  340. chown nobody: "$thisdir/$dir"
  341. done
  342. IFS="$ifs"
  343. done)
  344. done)
  345. done)
  346. done)
  347. # Ftp shares permissions
  348. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex "^\./ftp_$user$"`; do
  349. chgrp -R "$user" "$HOME/$dir"
  350. chmod -R ug=rw,o=r,a+X,g+s "$HOME/$dir"
  351. rm -rf "$HOME/$dir/Network Trash Folder"
  352. mkdir "$HOME/$dir/Network Trash Folder"
  353. chown nobody: "$HOME/$dir/Network Trash Folder"
  354. chmod a= "$HOME/$dir/Network Trash Folder"
  355. done
  356. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex "^\./ftp_${user}_ro$"`; do
  357. chown -R "$user": "$HOME/$dir"
  358. chmod -R u=rw,go=r,a+X "$HOME/$dir"
  359. rm -rf "$HOME/$dir/Network Trash Folder"
  360. mkdir "$HOME/$dir/Network Trash Folder"
  361. chown nobody: "$HOME/$dir/Network Trash Folder"
  362. chmod a= "$HOME/$dir/Network Trash Folder"
  363. done
  364. # Web shares permissions
  365. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./web_.*'`; do
  366. chown -R "$user": "$HOME/$dir"
  367. # chmod -R u=rw,go=r,a+X $webdir
  368. #TODO: Only cgi scripts (.cgi and .pl) should be executable
  369. chmod -R u+rw,go+r,a+X "$HOME/$dir"
  370. # leftover from ancient times with another policy
  371. if [ $NETATALK ]; then
  372. rm -rf "$HOME/$dir/Network Trash Folder"
  373. fi
  374. done
  375. # Web shares permissions
  376. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./websites$'`; do
  377. chown root: "$HOME/$dir"
  378. chmod a=r,u+w,a+X "$HOME/$dir"
  379. done
  380. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./websites/.*'`; do
  381. chown -R "$user": "$HOME/$dir"
  382. # chmod -R u=rw,go=r,a+X $webdir
  383. #TODO: Only cgi scripts (.cgi and .pl) should be executable
  384. chmod -R u+rw,go+r,a+X "$HOME/$dir"
  385. # leftover from ancient times with another policy
  386. if [ $NETATALK ]; then
  387. rm -rf "$HOME/$dir/Network Trash Folder"
  388. fi
  389. done
  390. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./webscripts$'`; do
  391. chown root: "$HOME/$dir"
  392. chmod a=r,u+w,a+X "$HOME/$dir"
  393. done
  394. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./webscripts/.*'`; do
  395. chown -R $user: "$HOME/$dir"
  396. # chmod -R u=rw,go=r,a+X $webdir
  397. #TODO: Only cgi scripts (.cgi and .pl) should be executable
  398. chmod -R u+rw,go+r,a+X "$HOME/$dir"
  399. done
  400. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./webdata$'`; do
  401. chown "$user": "$HOME/$dir"
  402. chmod a=r,u+w,a+X "$HOME/$dir"
  403. done
  404. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./webdata/.*'`; do
  405. chown -R "$user": "$HOME/$dir"
  406. chmod -R u=rw,go=,u+X "$HOME/$dir"
  407. done
  408. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./webshareddata$'`; do
  409. chown "$user": "$HOME/$dir"
  410. chmod a=r,u+w,a+X "$HOME/$dir"
  411. done
  412. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./webshareddata/.*'`; do
  413. chown -R "$user:" "$HOME/$dir"
  414. chmod -R u=rw,go=r,a+X "$HOME/$dir"
  415. done
  416. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./webphpsites$'`; do
  417. chown root: "$HOME/$dir"
  418. chmod u=rw,go=r,a+X "$HOME/$dir"
  419. done
  420. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./webphpsites/.*'`; do
  421. chown -R "$user":www-data "$HOME/$dir"
  422. # chmod -R ug=rw,o=r,a+X $dir
  423. chmod -R ug=rw,o=,ug+X "$HOME/$dir"
  424. done
  425. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./webphpdata$'`; do
  426. chown root: "$HOME/$dir"
  427. chmod a=r,u+w,a+X "$HOME/$dir"
  428. done
  429. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./webphpdata/.*'`; do
  430. chown -R "$user":www-data "$HOME/$dir"
  431. chmod -R ug=rw,o=,ug+X "$HOME/$dir"
  432. done
  433. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./weblogs$'`; do
  434. chown -R "$user": "$HOME/$dir"
  435. chmod -R u=rw,g=r,o=,ug+X "$HOME/$dir"
  436. done
  437. # Dummy user restrictions
  438. if [ -n "$REALUSERS_GROUPNAME" -a -n "$DUMMYSHAREDIR" -a -n "$DUMMYSHAREOWNER" -a -n "$DUMMYSHARENAME" ]; then
  439. [ -e $DUMMYSHAREDIR/$user ] \
  440. || mkdir $DUMMYSHAREDIR/$user
  441. chown $DUMMYSHAREOWNER: $DUMMYSHAREDIR/$user
  442. chmod u=rw,go=r,a+X $DUMMYSHAREDIR/$user
  443. if [ -e $HOME/$DUMMYSHARENAME ]; then
  444. if [ -L $HOME/$DUMMYSHARENAME ]; then
  445. ln -sf $DUMMYSHAREDIR/$user $HOME/$DUMMYSHARENAME
  446. chown $user: $HOME/$DUMMYSHARENAME
  447. else
  448. echo "WARNING: $HOME/$DUMMYSHAREDIR exists already. Leaving it as is..."
  449. fi
  450. else
  451. ln -s $DUMMYSHAREDIR/$user $HOME/$DUMMYSHARENAME
  452. chown $user: $HOME/$DUMMYSHARENAME
  453. fi
  454. if [ -n "$DUMMYAPACHECFG" -a -n "$DUMMYAPACHESHAREDIR" ]; then
  455. if [ -f /etc/apache/include.d/$DUMMYAPACHECFG -a -x /etc/init.d/apache ]; then
  456. if [ -e /etc/apache/include.d/$DUMMYAPACHECFG-$user ]; then
  457. echo "/etc/apache/include.d/$DUMMYAPACHECFG-$user exists already. Ignoring..."
  458. else
  459. echo "# Created automatically by adduser.local
  460. <Location /$DUMMYAPACHESHAREDIR/$user>
  461. <Limit GET POST>
  462. require user $user
  463. </Limit>
  464. </Location>" \
  465. > /etc/apache/include.d/$DUMMYAPACHECFG-$user
  466. apache_reload_needed="1"
  467. fi
  468. fi
  469. fi
  470. fi
  471. echo "."
  472. done
  473. if [ $XCHANGE ]; then
  474. for USER in $(ls $XDIRREAL); do
  475. id $user >/dev/null 2>&1 || rm -rf $XDIRREAL/$user
  476. done
  477. fi
  478. if [ "$apache_reload_needed" ]; then
  479. apache_do_reload=""
  480. case runmode in
  481. interactive)
  482. echo -n "Apache config changed. Reload Apache now (Y/n)? "
  483. read apache_reload
  484. case $apache_reload in
  485. y|Y|"")
  486. apache_do_reload="1"
  487. ;;
  488. esac
  489. ;;
  490. force)
  491. apache_do_reload="1"
  492. ;;
  493. *)
  494. echo "Apache config has changed. Remember to reload Apache...!"
  495. ;;
  496. esac
  497. if "$apache_do_reload" ]; then
  498. /etc/init.d/apache force-reload
  499. fi
  500. fi